How to turn input boolean toggle switch (and icon) to off after automation performed

How do I turn the input boolean toggle switch (and icon) to off after the automation is performed. Here’s my automation to turn off ALL selected lights at the push of a button, or using the exposed toggle in Google Assistant.

Works fine, waits 10 seconds, turns off selected lights, but if invoked by the switch on the panel, the icon in the panel doesn’t go back to the off (unlit) condition.

alias: Toggle All Lights Off
description: Lights Off with Bedtime Helper Boolean
trigger:
  - platform: state
    entity_id:
      - input_boolean.toggle_night_light_mode
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 10
condition: []
action:
  - service: light.turn_off
    data:
      transition: 1.5
    target:
      entity_id:
        - light.terrace_z_wave_dimmer_switch
        - light.leviton_dg15s_light
        - light.pot_lights_north_switch_leviton_light_2
        - light.guest_br_bulbs
        - light.master_bedroom_bedside_lamp_group
        - light.jasco_products_43080_light
        - light.front_door_dimmer_switch_z_wave
        - light.upstairs_hallway_dimmer_zooz
        - light.guest_bathroom_main_light_switch_light_2
        - light.guest_bedroom_lamp_switch_jasco_light_2
        - light.led_strip_light_terrace_light
  - service: switch.turn_off
    data: {}
    target:
      entity_id:
        - switch.700_series_outdoor_double_plug
        - switch.700_series_outdoor_double_plug_2
        - switch.kitchen_led_switch_z_wave_jasco
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.toggle_switch_to_turn_on_night_mode
mode: single

If you want to use an automation, you’ll have to turn off the input boolean after your automation runs.

Another option is use a button helper as a trigger instead of your input boolean…

Finally, because it looks like you’re trying to create an easy way to have all lights on or off… You could create a group with all those lights… the state of the group would actually be the aggrigate state of the entities…

Yes I should and will certainly use a group.

But regarding your first comment, didn’t I turn it off at the bottom of the automation?

No, you didn’t. Check the entity_ids

1 Like

Woops! Thanks so much.

Be careful with the automation you posted, there is a non-obvious “gotcha”. If you happen to trigger the automation a second time while the first is running, your input boolean won’t be reset because the second instance will be cancelled without executing any actions. Next time you want to trigger the automation, the trigger won’t work as the boolean will already be “on”.

Ask me how I know. :slight_smile:

There are several ways to work around it - you can have an automation that turns off the input boolean if it happens to be on for more than a few minutes, or you can change the mode from “single” and check if more than 1 instance is running with a choose and simple turn off the boolean only in the second instance and quit.

Just commenting on a painful lesson learned.

1 Like

I use a custom button card, and tie the biolean to the card as the entity. The action is “toggle”, and then I use the state of the boolean to trigger whatever I want. Works great, and I don’t have to turn anything on or off since the simple press of the button in the dashboard does it for me.

I never want to miss a good story. How do you know?

1 Like