hello
how can i add a “multi” switch to my config?
i need a solution for
10:00-10:30 ON
12:00-12:30 ON
15:00-15:30 ON
20:00-21:00 ON
the rest of the day is OFF.
sorry, but i have no idea what is the right automation-code.
regard
hello
how can i add a “multi” switch to my config?
i need a solution for
10:00-10:30 ON
12:00-12:30 ON
15:00-15:30 ON
20:00-21:00 ON
the rest of the day is OFF.
sorry, but i have no idea what is the right automation-code.
regard
Do you mean you have a switch entity (i.e., something named switch.xxx
) and you want an automation to turn it on and off per the schedule you mentioned? If so, you could do that like this:
automation:
- alias: Turn switch on for a while at certain times
trigger:
- platform: time
at: '10:00:00'
- platform: time
at: '12:00:00'
- platform: time
at: '15:00:00'
- platform: time
at: '20:00:00'
action:
- service: switch.turn_on
entity_id: switch.xxx
- delay: >
{% if now().hour == 20 %}
'01:00:00'
{% else %}
'00:30:00'
{% endif %}
- service: switch.turn_off
entity_id: switch.xxx
Just wanted to say that this is a very elegant solution to OP’s question!
Thx for your solution. I will try it…
Regard
hi, i try your script. my switch turns on, but not off.
# Pumpe Pool An
- alias: 'Pumpe Sandfilteranlage'
trigger:
- platform: time
at: '10:00:00'
- platform: time
at: '12:00:00'
- platform: time
at: '14:00:00'
- platform: time
at: '16:00:00'
- platform: time
at: '18:00:00'
- platform: time
at: '20:00:00'
action:
- service: switch.turn_on
entity_id: switch.pumpepool
- delay: >
{% if now().hour == 20 %}
'01:00:00'
{% else %}
'00:30:00'
{% endif %}
- service: switch.turn_off
entity_id: switch.pumpepool
Sorry, try removing quotes from times in delay statement.