Did anyone already think about using the forecast temperature as additional as the input parameter?
If I imagine a day with >30°C I would assume that closing the blinds once the temperature is above a threshold is already too late to keep the temperature low (i.e. closing them earlier be needed).
These are useful extensions for the blueprint, @erik7. Would be great, to see the logic for open doors in the blueprint.
At the moment I use a logic in addition to the shading to open or close my blinds in the morning and in the evening. The logic is based on the brightness and the time. Open the blinds when a certain lux value is reached or at the latest when it is e.g. 9:00 o’clock. The same in the evening. Close the blinds when a certain lux value is reached (it is dark) or when it is 21:00.
This is my basic logic, so to speak. The shading logic is then added, so that in the morning of a summer day, the blinds do not open fully, but move directly to the shading position.
Can something like this be added to the Blueprint?
Changed Al little bit the Blueprint with external TempSensor…
In the line value_template: "{{ state_attr(cover_e, 'current_position') < open_position }}", the automation script is checking the current position of the shutter (retrieved by state_attr(cover_e, 'current_position')) against the predefined opening position (open_position). If the current position is less than the opening position, this implies that the shutter is not fully open and thus the action to open the shutter will be executed. Conversely, if the current position is equal to or more than the opening position, it means the shutter is already at the desired position, and the action to open the shutter will be skipped. This mechanism prevents the system from redundantly sending the signal to open the shutter when it’s already open.
blueprint:
name: sun protection v3
description: close cover when sun is shining and open when stops
domain: automation
source_url: https://gist.github.com/mougeat/bec9f93c723c8e7d1a9c64c2592fa471
input:
cover_entity:
name: cover
selector:
entity:
domain: cover
sun_position_start:
name: sun azimuth position start
description: Sun azimuth. when sun is below this value, shutter could be triggered
default: 89
selector:
number:
min: 0
max: 360
unit_of_measurement: °
sun_position_end:
name: sun azimuth position end
description: Sun azimuth. when sun is over this value, shutter could be triggered
default: 200
selector:
number:
min: 0
max: 360
unit_of_measurement: °
sun_elevation_start:
name: sun elevation to start
description: Sun elevation. when sun is over this value, shutter could be triggered
default: 32
selector:
number:
min: -100
max: 360
unit_of_measurement: °
weather:
name: Weather service
selector:
entity:
domain: weather
sensor:
name: Außensensor
selector:
entity:
domain: sensor
outdoor_temp_1:
name: Pos1 - Outdoor temperature (Low)
description: Temperature above which the shutters will close
default: 19
selector:
number:
min: 0
max: 30
unit_of_measurement: °C
close_position_1:
name: Pos1 - Intermediate Closing position for lower temperature
description: Position at which the shutter should close
default: 35
selector:
number:
min: 0
max: 100
outdoor_temp_2:
name: Pos2 - Outdoor temperature (High)
description: Second temperature threshold above which the shutters will close
default: 25
selector:
number:
min: 0
max: 30
unit_of_measurement: °C
close_position_2:
name: Pos2 - Maximum Closing Position for higher temperature
description: Second position at which the shutter should close
default: 18
selector:
number:
min: 0
max: 100
open_position:
name: Opening position
description: Position at which the shutter should open
default: 100
selector:
number:
min: 0
max: 100
variables:
cover_e: !input cover_entity
var_e: "{{ 'var.' + cover_e[6:] }}"
protection_begin: !input sun_position_start
protection_end: !input sun_position_end
elevation_begin: !input sun_elevation_start
outdoor_temp: !input outdoor_temp_1
outdoor_temp_2: !input outdoor_temp_2
close_position: !input close_position_1
close_position_2: !input close_position_2
open_position: !input open_position
weather_service: !input weather
sensor: !input sensor
mode: parallel
trigger:
- platform: time_pattern
minutes: "/5"
condition:
- condition: sun
before: sunset
after: sunrise
action:
- choose:
##########################################################.
# close cover - second temperature threshold
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: template
value_template: "{{ states(var_e) != '1' }}"
- condition: template
value_template: "{{ state_attr('sun.sun', 'azimuth') > protection_begin and state_attr('sun.sun', 'azimuth') < protection_end and state_attr('sun.sun', 'elevation') > elevation_begin }}"
- condition: or
conditions:
- condition: template
value_template: "{{ states(weather_service) == 'partlycloudy' }}"
- condition: template
value_template: "{{ states(weather_service) == 'sunny' }}"
- condition: template
value_template: "{{ states(sensor) |float > outdoor_temp and states(sensor) |float <= outdoor_temp_2 }}"
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ close_position_2 }}"
service: cover.set_cover_position
##########################################################
# close cover - first temperature threshold
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: template
value_template: "{{ states(var_e) != '1' }}"
- condition: template
value_template: "{{ state_attr('sun.sun', 'azimuth') > protection_begin and state_attr('sun.sun', 'azimuth') < protection_end and state_attr('sun.sun', 'elevation') > elevation_begin }}"
- condition: or
conditions:
- condition: template
value_template: "{{ states(weather_service) == 'partlycloudy' }}"
- condition: template
value_template: "{{ states(weather_service) == 'sunny' }}"
- condition: template
value_template: "{{ states(sensor) |float > outdoor_temp_2 }}"
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ close_position }}"
service: cover.set_cover_position
##########################################################
# open cover
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: sun
before: sunset
after: sunrise
- condition: template
value_template: "{{ (state_attr('sun.sun', 'azimuth') < protection_begin or state_attr('sun.sun', 'azimuth') > protection_end or state_attr('sun.sun', 'elevation') < elevation_begin) }}"
- condition: template
#value_template: "{{ is_state(cover_e, 'open') == false }}"
value_template: "{{ state_attr(cover_e, 'current_position') < open_position }}"
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ open_position }}"
service: cover.set_cover_position
Is there any integration that you use, which provides the Azimuth start position, and so on? trying to make this even more automated during the summer.
Suggestions for improvement would be to support multiple covers at the same time. If anyone has any suggestions on how to accommodate that change, please share your findings.
Finally, kudos to the @mougeat, after setting everything up, it is working as expected.
Invalid config for [var]: [cover_cover.sunilus_io] is an invalid option for [var]. Check: var->var->cover_cover.sunilus_io. (See /config/configuration.yaml, line 56).
Would this Blueprint be dependent on the northern hemisphere?
I had set this up yesterday, however at sunset nothing happened and again this morning nothing happened with my cover.
I have checked, current_position is available.
Only thing I can think of is the Sun position is reversed for me here in the Southern Hemisphere:
Sunrise is at 87° @ 06:24 then it drops down all the way to 0° at mid-day, then it jumps to 360° and continues to go down from there until sunset at 270° @ 18:24
Now in the Northern Hemisphere, you guys don’t go past 0/360° and thus the Blueprint probably needs some tweaking for Southern Hemisphere…
works great. and just the thing iwaslooking for- one thing i miss.
The possibility to choose an exception. Could be a door or window sensor, so that the cover will stay open if door/window is open…
When I manually open or close a blind the state of the cover_e is updated live.
So, being no real programmer, I’m a bit puzzled by the use and function of the var_e variable in combination with the cover_e. Could you shed some light on this?
Hello,
I used to have this blueprint working like a charm, but recently not working anymore. When troubleshooting the automation, realize that I am getting an error at:
conditions/5
Error : In ‘template’ condition: UndefinedError: ‘state’ is undefined which correspond to the following line:
condition: template
value_template: >-
{{ state_attr(‘sun.sun’, ‘azimuth’) > protection_begin and
state_attr(‘sun.sun’, ‘azimuth’) < protection_end and
state_attr(‘sun.sun’, ‘elevation’) > elevation_begin }}
When running the template with numeric values, I am gettig same issue:
value_template: >-
{{ state_attr(‘sun.sun’, ‘azimuth’) > 71 and state_attr(‘sun.sun’,
‘azimuth’) < 285 and state_attr(‘sun.sun’, ‘elevation’) > 15 }}
But when using the same in developpment tool-> Model, the result is true (no errors).
Any clue where could be the issue ?
Thanks,