I need to be able to turn 4 relays ON at the same time but turning OFF requires one of the relays to wait 30 seconds after the other three are turned off.
When looking at the documentation, all I see is the “flash” option which I don’t believe is what I need.’
ON → Relays 1, 2, 3 and 4 are turned ON at the same time
OFF → Relays 1, 2 and 3 are turned off. This trigger a 30 second timer before relay 4 is turned off.
Is there a built-in function or do I need to create a script for this (like for Digital Loggers’ “Pro Switch 7”, which uses LUNA)
you need a script
#name it relays_on
script:
relays_on:
alias: "Turn ON All Relays"
sequence:
- service: switch.turn_on
target:
entity_id:
- switch.relay1
- switch.relay2
- switch.relay3
- switch.relay4
#name it relays_off
script:
relays_off:
alias: "Turn OFF Relays With Delay"
sequence:
- service: switch.turn_off
target:
entity_id:
- switch.relay1
- switch.relay2
- switch.relay3
- delay: "00:00:30"
- service: switch.turn_off
target:
entity_id: switch.relay4
and to call it
service: script.relays_on
service: script.relays_off
you can use a helper to make an automation input_boolean.relay_toggle
alias: Toggle Relays with Automation
trigger:
- platform: state
entity_id: input_boolean.relay_toggle
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.relay_toggle
state: "on"
sequence:
- service: script.relays_on
- conditions:
- condition: state
entity_id: input_boolean.relay_toggle
state: "off"
sequence:
- service: script.relays_off
something like this
Another option would be to set up a Template Switch.
thats correct
something like this
template:
- switch:
- name: "Relay Group"
turn_on:
- service: switch.turn_on
target:
entity_id:
- switch.relay_1
- switch.relay_2
- switch.relay_3
- switch.relay_4
turn_off:
- service: switch.turn_off
target:
entity_id:
- switch.relay_1
- switch.relay_2
- switch.relay_3
- delay: "00:00:30"
- service: switch.turn_off
target:
entity_id: switch.relay_4
value_template: >
{{ is_state('switch.relay_1', 'on') or
is_state('switch.relay_2', 'on') or
is_state('switch.relay_3', 'on') or
is_state('switch.relay_4', 'on') }}