Single automation template to set several input_booleans?

Hi,

for my Tiles I need an automation to set these input_booleans to Off except for the one that is selected and should be set On.

scenario:
select Tile Opstaan, -> Input_boolean.activity_opstaan turns On, -> and all other Booleans Off.

I was hoping to be able to do this in 1 automation, and not have to write a dedicated automation for all booleans, in On and Off variants…
For this reason I made them have the same format to be able to use input_boolean.activity_{} as template?

I did of course add the On command to the script itself, but still need the Off command for all others…or would it be as simple to have these input_booleans in a group, first in sequence turn them all off, and then second in sequence, turn the desired boolean on?

opstaan_direct:
  alias: Opstaan direct
  sequence:
    - service: input_select.select_option
      data:
        entity_id: input_select.activity
        option: Opstaan
    - service: homeassistant.turn_off
      data:
        entity_id: group.activity_select_booleans
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.activity_opstaan

Hope you can have a look, thanks,
Marius

input_boolean:
  activity_opstart:
    name: Opstart
    initial: off
  activity_opstaan:
    name: Opstaan
    initial: off
  activity_aan_de_slag:
    name: Aan de slag
    initial: off
  activity_gym:
    name: Gym
    initial: off
  activity_home_theater:
    name: Home theater
    initial: off
  activity_selamat_makan:
    name: Selamat makan
    initial: off
  activity_uit_huis:
    name: uit huis
    initial: off
  activity_naar_bed:
    name: Naar bed
    initial: off


entities:
          - entity: input_boolean.activity_opstart #script.opstart_direct
            service: script.turn_on
            entity_id: script.opstart_direct
            image: /local/activities/opstart75.png
          - entity: input_boolean.activity_opstaan # script.opstaan_direct
            service: script.turn_on
            entity_id: script.opstart_opstaan_direct
           # label: Opstaan
            image: /local/activities/opstaan75.png
          - entity: input_boolean.activity_aan_de_slag #script.aan_de_slag_direct
           # label: Aan de slag!
            image: /local/activities/aandeslag75.png
            service: script.turn_on
            entity_id: script.opstart_aan_de_slag_direct
          - entity: input_boolean.activity_uit_huis #script.uit_huis_direct
            # label: Uit huis
            image: /local/activities/uithuis75.png
            service: script.turn_on
            entity_id: script.uit_huis_direct

etc.

1 Like