Custom switch to toggle two devices with delay

I have two Wifi outlets that are integrated with my HomeAssistant. I want to create a custom switch to control both of them.

When turning the switch On i’d like both devices turned on.
When turning Off I’d like one of the devices to be turned off with the 2nd device turned off with a delay of 1-min. I want the switch to display as “Off” even while it’s delaying turning the second device off.

This could be summarized into three states:
On: Displays as on and both devices are on
Turning Off: Displays as off. First device off immediately and 2nd device is turned off in 1-minute
Off: Displays as off and both devices are off

I’m new to HomeAssistant and have searched around but don’t quite understand how to implement this. Any help appreciated, thank you!

1 Like

Switches only have two states, on or off. So no chance of turning off.

Things that can have more than two states: sensors, input_selects of which you can only control input_selects.

Write an automation to control the state of an input_select.

Thanks, yes I’ve looked at these docs but it’s not clear how I might implement the scenario above with a delay.

Put the delay in the automation actions.

I’m looking for an example of the scenario I described above.

It looks like I can use a custom switch to get the desired effect after all:

- platform: template
      friendly_name: "Hot Tub"
      value_template: "{{ is_state('switch.hot_tub_pump', 'on') }}"
        - service: switch.turn_on
          entity_id : switch.hot_tub_pump
        - service: switch.turn_on
          entity_id : switch.hot_tub_heater
        - service: switch.turn_off
          entity_id : switch.hot_tub_heater
        - delay: 60
        - service: switch.turn_off
          entity_id : switch.hot_tub_pump
1 Like

Sure that was what I thought of until you asked for this:

Which your chosen solution does not have.

I don’t need to display the three states, I just needed those states to happen and wanted to explain that it wasn’t a simple Turn On/Off and that I needed a delay on one switch while Turninig off. Maybe I could have worded differently but appreciate the help none the less!