I have an automation that updates the african_sunrise and african_sunset inputs every morning (Mozambique more specifically).
Then a separate automation (snippet) below is to turn on/off the lights as needed.
Turning on works as expected, but turning off the automation is triggered but doesn’t pass the condition to turn off the lights. I added a failsafe that runs every 15minutes to catch this for now, but defeats the purpose of the dynamic end time (minutes /15 ).
- id: '1601060469999'
alias: M Light Cycle
trigger:
- platform: time_pattern
minutes: /15
- platform: time
at: input_datetime.african_sunrise
- platform: time
at: input_datetime.african_sunset
condition: []
action:
- choose:
- conditions:
- condition: time
after: input_datetime.african_sunrise
before: input_datetime.african_sunset
sequence:
- service: switch.turn_on
data:
entity_id:
- switch.m1_outlet
- delay: 5
- service: switch.turn_on
data:
entity_id:
- switch.m4_outlet
default:
- service: switch.turn_off
data:
entity_id:
- switch.m1_outlet
- delay: 5
- service: switch.turn_off
data:
entity_id:
- switch.m4_outlet
mode: single
- id: '1608696862576'
alias: Setup Time Triggers
description: ''
trigger:
- platform: time
at: 01:00:00
- platform: homeassistant
event: start
condition: []
action:
- service: input_datetime.set_datetime
data_template:
time: '{{ state_attr(''sensor.mozambique_sun'', ''sunrise'') }}'
entity_id: input_datetime.african_sunrise
- service: input_datetime.set_datetime
data_template:
time: '{{ state_attr(''sensor.mozambique_sun'', ''sunset'') }}'
entity_id: input_datetime.african_sunset
mode: single
From the image you can see what the two input_datetimes are set to, and you can see that the outlet turned on at the correct time, but went past the sunset time and was turned off with the failsafe /15 trigger. I’m hoping I missed something simple in how choose interacts with time conditions and input_datetimes. Another set of eyes and/or things to try to fix the issue would be greatly appreciated.