Hi there, I’m pretty new to Home Assistant, but it already won my heart. Yesterday I found myself turning on and off sprinklers, as my 3yo likes to get under the sprinklers, making him chase from one sprinkler to the other. He loved it but I had manually to do all the turning-on/off. Today I spent my day finding an automation script that would do that for me with no success.
So far I created an input_boolean, which is going to be checked and as long as the condition is true, the automation would continue to loop, cycling through the four sprinklers I have. I also have a slider_input, where I can set the duration in seconds for a sprinkler to be on.
I guess my error lies in the scripts.yaml and the automation.yaml. Hope that someone can point me in the right direction.
my configuration.yaml
input_number:
sprinkler_timer_seconds:
min: 0
max: 20
input_boolean:
game_sprinklers_state:
my automation.yaml
- alias: game_loop
trigger:
platform: state
entity_id:
- input_boolean.game_sprinklers_state
to: "on"
action:
service: script.open_a_sprinkler
and my scripts.yaml
open_a_sprinkler:
sequence:
- alias: "Open a random sprinkler for x seconds"
repeat:
while:
- condition: state
entity_id:
- input_boolean.game_sprinklers_state
state: "on"
# Don't do it too many times
- condition: template
value_template: "{{ repeat.index <= 50 }}"
sequence:
- service: switch.turn_on
entity_id: 'switch.{{["terracesprinkler","terracesprinkler2","middlesprinkler","gatesprinkler"]|random}}'