Mode Select

Hi All,

I’m trying to create 4 modes.

Home, Away, Night, Other.

I’ve created 4 toggle helpers named as such.

How do I ensure that if one is “on” the rest are off.

I’ve tried creating 4 no automations that look like the below, switching the others respectively. The one for “home” being below.

Am I going about this all the wrong way. This is so much harder than smart things.

alias: Mode Set Home
description: ‘’
trigger:

  • platform: state
    entity_id: input_boolean.mode_home
    from: ‘Off’
    to: ‘On’
    condition: []
    action:
  • service: input_boolean.turn_off
    data: {}
    target:
    entity_id:
    - input_boolean.away
    - input_boolean.entertaining
    - input_boolean.night
    mode: restart

There may be a better solution to what you are trying to do, such as a Times of Day sensor or Input select. If you still want to use booleans you can use the following as an example of how to entrain them so that only one can be on at a time:

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: >-
    {{ ['input_boolean.test_bool_1', 'input_boolean.test_bool_2', 'input_boolean.test_bool_3'] 
    | reject('eq', trigger.to_state.entity_id) | list -}}
mode: single
1 Like

Thanks for that.

Where do I put that code?

I still haven’t grasped why there are so many different .YAML files and what to do with them at the right time!

It’s just an automation, so you can paste it into automations.yaml or you can use the GUI automation editor to create a new automation then use the “Edit in YAML” option.