Hello.
I got so much knowledge from this community that I want to share something what I did.
Below i present You the way which I made my window shutters fallow sun so it will not be dark in whole home but the sun will not heat up interior of house. IRL with outside shutter this drags temperatures by about 8 degrees.
I know there is probably elegant way of coding it but I did not touched my code since it started working.
Below is not including automation opening and closing shutters on sunrise or sundown since You probably already did it if You have shutters.
Here we go:
For simplifying thinking of automations I have crated adjusted azimuth. In simple words this is compensating what household is calling south and what actual south is You have to get this on Your own by doing some trigonometry on maps and change 27 in value template:
- platform: template
sensors:
sun_azimuth:
friendly_name: "Sun Azimuth"
unit_of_measurement: '°'
value_template: "{{ state_attr('sun.sun', 'azimuth')-27|round(0) }}"
Second thing is tu prepare input boolean that will be responsible for not allowing further automations to run for eg. while watching movies on screen or during winter when we are lacking sun. I made two separate for winter and watching movies but one should be enough.
I did this by adding two input booleans in Config > Helpers.
If you have shutters (dirven by mqtt) on balcony windows and contact snsors You will be interested in adding this kind of automations for each window ( by adjusting topic) . It simply blocks tasmota device for executing orders:
- id: "1601917502766"
alias: Roleta NG blokada
description: ""
trigger:
- platform: state
entity_id: binary_sensor.dws_okno_garaz_contact
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.dws_okno_garaz_contact
state: "on"
sequence:
- service: mqtt.publish
data:
topic: cmnd/roleta/RolNG/Backlog
payload: ShutterLock1 1
- conditions:
- condition: state
entity_id: binary_sensor.dws_okno_garaz_contact
state: "off"
sequence:
- service: mqtt.publish
data:
topic: cmnd/roleta/RolNG/Backlog
payload: ShutterLock1 0
default: []
mode: single
max_exceeded: silent
Next thing You want to do is to group shutters by “so called”/household
cardinal directions since we compensated that in first step. This can be don wherever you have Your cvers configured:
- platform: group
name: wschod # east
entities:
- cover.rolepw
- cover.rolelw
- platform: group
name: zachod #west
entities:
- cover.roleng
- platform: group
name: polnoc #north
entities:
- cover.rolelbw
- platform: group
name: poludnie #south
entities:
- cover.rolegos
- cover.rolept
- cover.rolelt
- cover.rolepbw
Main part: I have divided sun azimuth to diffrent directions and this is what triggers shutters. Shutters that are perpendicular (or almost) to sun rays are closed other one are slightly opened and those which are in shadow are opened.
- alias: Rolety 67,5
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 67
below: 90
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
- condition: time
after: 07:00:00
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 50
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 0
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 100
id: e7ebf041a7c040f6b8d095d140effe65
- alias: Rolety 90
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 90
below: 112
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
- condition: time
after: 07:00:00
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 0
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 100
id: eb9f4ea24be34926932fdf560fff826b
- alias: Rolety 112
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 112
below: 135
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
- condition: time
after: 07:00:00
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 0
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 50
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 100
id: 62b2bd85368d478f8b14d9e025e88cac
- alias: Rolety 135
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 135
below: 157
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
- condition: time
after: 07:00:00
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 20
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 20
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 100
id: 3dfe039f09df452288639237c8feddbd
- alias: Rolety 157
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 157
below: 180
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
- condition: time
after: 07:00:00
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 50
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 0
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 100
id: 30e049743d9742b6b87f47604bcfa4fe
- alias: Rolety 180
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 180
below: 202
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
- condition: time
after: 07:00:00
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 0
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 20
id: a88c2594c7db4b02a3d4b6a3e6aaf65f
- alias: Rolety 202,5
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 202
below: 225
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 0
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 0
id: 8d5782e3d02946f3a9b5a08180031bed
- alias: Rolety 225
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 225
below: 247
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 20
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 20
id: 74a7ee66e61b4d0388945e5e3034f197
- alias: Rolety 247
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 247
below: 270
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 20
id: a4a7ad17b9cd4fbf8c89fed4ae431081
- alias: Rolety 270
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 270
below: 292
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 0
id: 8203ca21aff7447ebf305f0a10f9f555
- alias: Rolety 292
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 292
below: 315
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 0
id: c709fccb95854e8487ba8b2ee870dd4a
- alias: Rolety 315
trigger:
platform: numeric_state
entity_id: sensor.sun_azimuth
above: 315
below: 350
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: input_boolean.kino_rolety
state: "off"
- condition: state
entity_id: input_boolean.zima_rolety
state: "off"
action:
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.polnoc
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.wschod
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.poludnie
position: 100
- service: COVER.SET_COVER_POSITION
data:
entity_id: cover.zachod
position: 20
id: ef9be8f176494a4e96afe3853c0943df
If You have some automations that will block above ones by input_booleans you can use this to get them to actual state. This is what I use when I am done watchng movies on projector:
- id: "1591476305397"
alias: Koniec seansu
description: ""
trigger:
- entity_id: input_boolean.kino
from: "on"
platform: state
to: "off"
condition: []
action:
#bunch of other things happening not related to this topic
- service: automation.trigger
data_template:
entity_id:
"{% if states('sensor.sun_azimuth') | float >= 45 and states('sensor.sun_azimuth')\
\ | float < 67 and is_state('sun.sun', 'above_horizon') %} \n automation.rolety_45\n\
{% elif states('sensor.sun_azimuth') | float >= 67 and states('sensor.sun_azimuth')\
\ | float < 90 and is_state('sun.sun', 'above_horizon') %} \n automation.rolety_675\t\
\n{% elif states('sensor.sun_azimuth') | float >= 90 and states('sensor.sun_azimuth')\
\ | float < 112 and is_state('sun.sun', 'above_horizon') %} \n automation.rolety_90\t\
\n{% elif states('sensor.sun_azimuth') | float >= 112 and states('sensor.sun_azimuth')\
\ | float < 135 and is_state('sun.sun', 'above_horizon') %} \n automation.rolety_112\t\
\n{% elif states('sensor.sun_azimuth') | float >= 135 and states('sensor.sun_azimuth')\
\ | float < 157 and is_state('sun.sun', 'above_horizon') %} \n automation.rolety_135\t\
\n{% elif states('sensor.sun_azimuth') | float >= 157 and states('sensor.sun_azimuth')\
\ | float < 180 and is_state('sun.sun', 'above_horizon') %} \n\
\ automation.rolety_157\t\n{% elif states('sensor.sun_azimuth') | float >=\
\ 180 and states('sensor.sun_azimuth') | float < 202 and is_state('sun.sun',\
\ 'above_horizon') %} \n automation.rolety_180\t\n{% elif states('sensor.sun_azimuth')\
\ | float >= 202 and states('sensor.sun_azimuth') | float < 225 and is_state('sun.sun',\
\ 'above_horizon') %} \n automation.rolety_2025\t\n{% elif states('sensor.sun_azimuth')\
\ | float >= 225 and states('sensor.sun_azimuth') | float < 247 and is_state('sun.sun',\
\ 'above_horizon') %} \n automation.rolety_225\t\n{% elif states('sensor.sun_azimuth')\
\ | float >= 247 and states('sensor.sun_azimuth') | float < 270 and is_state('sun.sun',\
\ 'above_horizon') %} \n automation.rolety_247\t\n{% elif states('sensor.sun_azimuth')\
\ | float >= 270 and states('sensor.sun_azimuth') | float < 292 and is_state('sun.sun',\
\ 'above_horizon') %} \n automation.rolety_270\t\n{% elif states('sensor.sun_azimuth')\
\ | float >= 292 and states('sensor.sun_azimuth') | float < 315 and is_state('sun.sun',\
\ 'above_horizon') %} \n automation.rolety_292\t\n{% elif states('sensor.sun_azimuth')\
\ | float >= 315 and states('sensor.sun_azimuth') | float < 350 and is_state('sun.sun',\
\ 'above_horizon') %} \n automation.rolety_315\t\n{% else %} \n automation.rolety_zamkniecie_zachod\n\
{% endif %} \n"
Well it is pretty much all of You hope It will be usefull and let me know that do You think about it.