Explanation
I have created a blueprint that allow to manage the cover with sun position. In sommer (for me) the sun over heat my house. So I will close / open my cover regarding sun elevation, azimuth and outside temperature.
Prerequisites
- Integration “Variable”
You will need to instal the “variable” HACS intergartion
https://github.com/snarky-snark/home-assistant-variables
in the config file (configuration.yaml) you will have to add the variable for each cover you will manage
var:
cover_NAME_OF_YOUR_COVER: #Replace NAME_OF_YOUR_COVER with the entity_id without cover. for exemple my entity_id is cover.bureau, the variable will be cover_bureau
friendly_name: "NAME YOU WOULD LIKE TO USE"
initial_value: 0
icon: mdi:bug
- Add Input Boolean
You will also have to create an Input Boolean : input_boolean.cover_manage_cover_with_sun in ordre to enable / disable the automation.
Blueprint:
Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)
Or import this Blueprint by using the forum topic / Gist URL:
https://gist.github.com/mougeat/bec9f93c723c8e7d1a9c64c2592fa471
# #Contrôle automatique des volets en fonction de la position du soleil et de la température extérieur
# #Auteur : Cyril Barthel
# #Version : 2.4
blueprint:
name: sun protection
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:
# target:
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
outdoor_temp:
name: Outdoor temperature
description: Temperature above which the shutters will close
default: 16
selector:
number:
min: 0
max: 30
unit_of_measurement: °C
close_time:
name: Closing time
description: Duration the shutter closes (max 60s)
default: 10
selector:
number:
min: 0
max: 60
unit_of_measurement: s
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
weather_service: !input weather
mode: parallel
trigger:
- platform: time_pattern
minutes: "/5"
condition:
condition: sun
before: sunset
after: sunrise
action:
- choose:
##########################################################
# close cover
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: or
conditions:
- condition: template
value_template: "{{ states(weather_service) == 'partlycloudy' }}"
- condition: template
value_template: "{{ states(weather_service) == 'sunny' }}"
- 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: template
value_template: "{{ state_attr(weather_service, 'temperature') > outdoor_temp }}"
sequence:
- data_template:
entity_id: "{{ cover_e }}"
service: cover.close_cover
- delay:
seconds: !input "close_time"
- data_template:
entity_id: "{{ cover_e }}"
service: cover.stop_cover
- condition: template
value_template: "{{ states(cover_e) == 'closed' }}"
- data:
entity_id: "{{ var_e }}"
value: 1
service: var.set
##########################################################
# open cover
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
# - condition: and
# conditions:
# - condition: template
# value_template: "{{ states(weather_service) != 'partlycloudy' }}"
# - condition: template
# value_template: "{{ states(weather_service) != 'sunny' }}"
- condition: template
value_template: "{{ states(var_e) == '1' }}"
- 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) }}"
sequence:
- data_template:
entity_id: "{{ cover_e }}"
service: cover.open_cover
- condition: template
value_template: "{{ states(cover_e) == 'open' }}"
- data:
entity_id: "{{ var_e }}"
value: 0
service: var.set
Changelog
- 27.03.2022 : Initial version
- 28.03.2022 : add Time to close, add condition to check if the cover close or open, because my cover loose often connection.
- 09.06.2022 Remove trigger confitions and change in order to be triggerd every 5 mintues and add condition to be fired only the day
- 09.06.2022 Clarification with the use of variable