Hi guys, I need help please. I want my shutters to open not earlier than 6:30 in the morning, but not when it is still dark.
I have two programs. The first is opening at 6:30 when the sun is already above horizon. This works perfect for summer.
trigger:
- at: 06:30:00
platform: time
condition:
- after: sunrise
condition: sun
With the second program I want to open 25 minutes prior sun rise, but not before 6:30.
trigger:
- event: sunrise
offset: -00:25:00
platform: sun
condition:
- after: 06:30:00
condition: time
Currently sun rises 06:35, less 25 minutes which is 06:10. This is before 06:30 and both of the programs not firing an action.
You haven’t posted full code so it’s difficult to comment.
Why do you want two automations doing the same things but for different times ?
This may be central to your solution
Usually when you have two triggers (ie open at 06:30 (if sun has risen) or open at sunrise (if after 06:30) you need both triggers and both conditions.
thank you @Mutt and @Burningstone for your fast response. I believe Burningstone´s example works. I have other automation’s with multiple triggers and conditions, but this did not come present in my mind for this occasion. Will try and report back.
this still fails. Looking at the example that sun will rise at 06:35. The offset triggers already at 06:10 and will not meet the conditions. Nothing will happen. Still don´t get a clue how to make it smarter.
Of course nothing happens at 6:10, you said you don’t want to open them before 6:30.
Let’s say sun rises at 6:35, so the first trigger is 25 min earlier at 6:10, nothing happens because you don’t want to open before 6:30. Then at 6:30 the second trigger happens, this will fire because its after 6:29 and after sunrise.
06:35 is just an example to simulate the problem. I have a dead time from 06:30 to 06:55 because of the offset. If sun rises at 07:00 it would work again, because it meets the 06:29 condition.
I want to open shutters in general 25 minutes prior sun rise but not earlier than 06:30.
The only way to incorporate the before offset into a condition is to either break this into two automations or to use templates to calculate when 25 mins before sunrise is. Are you okay with templates ?
what a great surprise to see some code! I was out for a couple of hours hence the delay in my response. My automation is not a secret at all, I just didn´t want to provide non essential information. I will look at your code now, not sure if I understand everything, but will try. Thank you!
I have a workday binary sensor, which means there is another program for the weekend. First the shutters will be lifted to 40% and 15 minutes later they are fully open.
- id: 4f7ae7f8e6da4376b004404e041e0916
alias: Jalousien Lux opening workday
description: triggered from sun but not before 06:30:00
trigger:
- event: sunrise
offset: -00:25:00
platform: sun
condition:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- after: 06:30:00
condition: time
action:
- data:
entity_id: group.all_covers_homematic
position: 40
service: cover.set_cover_position
- entity_id:
- cover.rfy_0b0101_1
- cover.rfy_0b0102_1
service: cover.stop_cover
- delay: 00:15:00
- data:
entity_id: group.all_covers_homematic
position: 100
service: cover.set_cover_position
- entity_id:
- cover.rfy_0b0101_1
- cover.rfy_0b0102_1
service: cover.open_cover
initial_state: 'true'
I will probably follow another approach as our lovely planet sun´s elevation / brightness is not linear and the 20 minutes offset would work currently, but not on the darkest day. On the 21st of December the sun rise is 8:00 and opening shutters 7:40 is too late for me anyway. https://www.suncalc.org/
I possibly will do two or more automations for seasons, like I have for my fountain with condition templates. This would enable me to trigger the shutters per season.
- id: '1550348476838'
alias: Vorgarten Brunnen aus
description: February 1st to November 15th
trigger:
- entity_id: sun.sun
for: '1:00:00'
from: above_horizon
platform: state
to: below_horizon
- above: '10'
entity_id: sensor.wind_speed
platform: numeric_state
condition:
- condition: template
value_template: '{% set n = now() %} {{ not (n.month == 11 and n.day >=16 or n.month
== 12 and n.day <= 31 or n.month == 1 and n.day <= 31) }}
'
action:
- data:
entity_id: switch.neq0950565_2
service: homeassistant.turn_off
initial_state: 'true'
I want to share with you my final solution. I had to figure out that it is not a good approach using time parameters for dependencies related to the sun. Almost all required background can be found in our manuals for Sunset / Sunrise Triggers Sunset / Sunrise trigger.
I used a sun calculator of my choice to lookup some extreme scenarious to proof conditions and triggers make sense SunCalc.org
I am now using elevation angle of “-5°”, which I can combine with conditions. I have two programs for easy managing work days and weekends. This now works flawless and is exactly what I wanted to achieve