I was customizing the above code for a different switch where instead of the preset time triggers, the switch on time is set by a helper(H1) and the on hours(H2) is also set by a helper
For the last part of the code, to switch off the device, for the datetime variable what would be the correct syntax so it the switch off time is on time (H1)+on hours(H2)
I tried >{{states(‘input_datetime.5x5_lights_on_time’)}}, but it yields an error
Message malformed: template value should be a string for dictionary value @ data[‘action’][1]['data
Thank you, this works perfectly, btw, I just have the time since the switches go through the routine daily.
The helper (off time) does not update the value till the automation is run, which I get,however is there anyway where I can create a time helper that has it’s value conditional upon a different helper?
And remove the off time setting service from the on automation as you no longer need it (it updates automatically):
alias: Watering
description: ''
trigger:
- platform: time
at: '07:30:00'
- platform: time
at: '12:30:00'
- platform: time
at: '17:30:00'
condition: []
action:
- service: switch.turn_on
target:
entity_id: switch.sonoff_
The only issue here is that you cant edit the off time directly if you ever need to. Say you wanted to cut the time short for some reason, you’d have to change the on_hours input number or on time.