I’m working on a Sprinkler controller and run an on_time
automation from the Time component.
The on_time
section checks every minute if a scheduled time matches the current time, and if so I enable a relay and delay for a specified amount of time and disable the relay. I continue with the rest of the relays.
I was wondering is it possible to stop execution remotely (without a physical button/switch) of the on_time
code? I want to stop the execution in case of an emergency or just switching from a scheduled watering to manual if I have to check a specific relay.
Here is a snippet of code:
# Time based automations.
time:
# Program 1 Schedule
- platform: homeassistant
id: homeassistant_time
on_time:
- seconds: 0
minutes: /1
then:
# Check if Program 1 Start Time is equal to the current time
- if:
condition:
lambda: 'return scheduled_runtime(id(ha_program1_start_time).state.c_str());'
then:
# Check if Program 1 is enabled
- if:
condition:
lambda: 'return id(program1_state) == 1;'
then:
# Check if Program 1 Run Day is enabled
- if:
condition:
lambda: 'return id(program1_run_days)[id(homeassistant_time).now().day_of_week - 1] == 1;'
then:
# Change Program 1 Status from 'Not Running' to 'Running'
- homeassistant.service:
service: input_boolean.turn_on
data:
entity_id: input_boolean.sprinkler_program1_status
# Check if Station 1 duration is greater than 0
- if:
condition:
lambda: 'return atoi(id(ha_sprinkler_program1_station1_run_time).state.c_str()) > 0;'
then:
- switch.turn_on: station1
- delay: !lambda 'return atoi(id(ha_sprinkler_program1_station1_run_time).state.c_str()) * 1000 * 60;'
- switch.turn_off: station1
The only thing I can think of is to use the Restart Switch
as the sprinkler will reboot with all the relays will be off but with a side effect of a 10 second or so delay since the esp device will lose network connectivity.
switch:
- platform: restart
name: "Sprinkler Controller Stop"