Multiple chained Input booleans - how to?

So in my past config I have used Input booleans as scene switches. When eg the “cleaning” light scene turns on - “Cosy”, “part”, and “normal” turn off. This was set up as an automation. I have moved and upgraded my HA with new scenes, and now I want to accomplish the same WITHOUT having to tweak it all in my automations, so I am wondering if anyone successfully have set up a solution where an activation of any of a given set of input boleans turns off all but the activiated one within the same group.

Sound like an input select but harder to set up.

But nicer looking?:wink:

I don’t know if this is exactly what you’re looking for, but this is something I put together a while ago…

alias: Entrained Booleans (only 1 on at a time)
description: ''
trigger:
  - platform: state
    entity_id:
      - input_boolean.test_bool_1
      - input_boolean.test_bool_2
      - input_boolean.test_bool_3
    to: 'on'
condition: []
action:
  - service: input_boolean.turn_off
    target:
      entity_id: '{{ inactive_bools }}'
variables:
  inactive_bools: >-
    {{ expand(states.group.test_bools) 
    | rejectattr('entity_id', 'eq', trigger.to_state.entity_id)
    | map(attribute='entity_id') | list -}}
mode: single

2 Likes

There’s a service to turn on a scene but none to turn it off so how are using an input_boolean as a switch to turn a scene on/off?

It might be! I don’t, however, quite get where you place the yaml. In my current setup, I use automations for selecting a boolean to use as switches for the scene. That means that for each automation, I have listed all the booleans and turn them on or off based on which scene is active. I would preferably like them to reside in say a script, so when I initiate a scene with a corresponding boolean - all other scene boleans are turned off.

I agree an input_select sounds much easier, but if you really want a group of input booleans, you could just write a blueprint (similar to the automation you posted) that takes a group of input_booleanss as an input. Then create one automation (super-simple - based on the blueprint) for each group if input_booleans. You’d still have a one automation for each group, but it’d only be a few lines of YAML and the blueprint would ensure consistent behavior among all the groups.

If you want to emulate turning off SceneA, you could snapshot the current state of all the entities affected by turning on SceneA as (dynamically-created) SceneB. Then you could activate SceneB when you “turn off” SceneA.

Emphasis on the word “emulate” because the fact is that a scene in Home Assistant can only be activated, not deactivated. What you described is perfectly legitimate but represents the activation of two separate scenes.

I just wanted to ensure this concept was clear to other readers to prevent giving the false impression that you can easily reverse the actions of a scene just by deactivating it; there is no deactivation.

FWIW, in a future release, scene will have a proper state value. Currently, it’s fixed at “scening” but in the near future it will be a timestamp representing when the scene was activated (turned on). This will make it easier to use an automation to detect, with a simple State Trigger, when a scene is activated. Currently one must use an Event Trigger.

Thanks for the in depth answer! In my past set-up, I use the booleans as switches to emulator the state. As you say, the scene is currently stateless, I need to change the state of the other booleans based on the latest set to on. I find the booleans to be working better with Google home than the input selects, but it might be error behind keyboard on my end

I also have some input_booleans exposed to Google so I can trigger things via voice command. I think the input_button that looks like it’ll be in the next (2022.02) release may be a better option. Planning to experiment with that once available.