I have made a Fibaro Roller Shutter 2 in a box on the wall. created the following code for automated sunscreen. it is still a little bit rough but it is working ok. It is based on the Dutch Buienradar data.
Used some Berker push buttons for manual control.
- alias: Sunscreen down
initial_state: 'on'
trigger:
platform: state
entity_id: sun.sun
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
above: 0 ## Sun should be above the horizon, not below
- condition: state
entity_id: cover.level
state: closed
for:
minutes: 30 ## Trying to prevent a crazy repetitive up-and-down action
- condition: sun
before: sunset
before_offset: -00:45:00 ## Some time before sunset, there's no point in rolling out anymore
- condition: numeric_state
entity_id: sensor.br_wind_force
below: 6 ## I still have to tune this value
- condition: numeric_state
entity_id: sensor.br_precipitation_forecast_total
below: 0.1 ## Almost no rain in the next 60 minutes
- condition: template
value_template: '{{ now().month > 2 }}' ## Starting March
- condition: template
value_template: '{{ now().month < 10 }}' ## Ending October
- condition: numeric_state
entity_id: sensor.br_irradiance
above: 400 ## This indicates direct sunlight on my location (as in: not cloudy)
action:
- service: cover.set_cover_position
data:
entity_id: cover.level
position: 40
- service: notify.group
data:
title: Sunscreen
message: 'Sunscreen is down because of the sun'
- alias: Sunscreen up
initial_state: 'on'
trigger:
- platform: sun
event: sunset
offset: -00:45:00
- platform: numeric_state
entity_id: sensor.br_wind_force
above: 6
- platform: numeric_state
entity_id: sensor.br_precipitation_forecast_total
above: 0.1
- platform: numeric_state
entity_id: sensor.br_irradiance
below: 200
for:
minutes: 10
condition:
condition: state
entity_id: cover.level
state: open
for:
seconds: 30 ## The screen takes some time to fully roll up or down, I don't want it changing direction half way
action:
- service: cover.close_cover
entity_id: cover.level
- service: notify.group
data:
title: Sunscreen
message: 'Sunscreen is pulled up'
Edit: In the mean time i updated the sautomation with some extra conditions. This conditions do check the position of the sun (azimuth) and the solar power generation of my pv installation. With these checks the automation is more reliable.
- condition: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.azimuth }}'
above: 80 ## This is the position where the sunlight starts hitting the window
below: 250 ## This is about west, sun down
- condition: numeric_state
entity_id: sensor.power_generation
above: 750 # Solar generation has to be more than 750w.