Best solution for On - Auto - Off switch?

There are quite a lot of controls I would like to use an On, Auto or Off switch for. Where I now have an Input_boolean for Auto (on or off), and another one for when auto is off: (manually On or Off).

I would like to have a switch with three options: On, Auto, Off, but it seems not there in HA.

What is your idea for a better solution? Perhaps with a Dropdown / input_select?

Yep input_select is the best fit for this.

1 Like

If you search for “three state switch” it will show requests dating back to 2017. In other words, there’s a long-standing interest in a switch entity with three states but no interest in implementing it because an input_select does the job. The usual complaint is that the input_select’s appearance in the UI is not like a switch but there’s not much that can be done about that (short of inventing some kind of special card).

The only alternative I can think of is to create three Input Booleans, displayed as buttons, and link them so they behave like “radio buttons” (only one of the three buttons can be on at any time).

1 Like

After you follow up on Taras’ suggestion above, I’ve got a similar situation where a tri-state indicator was helpful. I coded it as an input_select helper with three options. I have an automation that switches the options as it runs (so I have a visual indication of where in the cycle it is).
In your case you can change the tap_action to a service call to input_select.select_next with cycle enabled and a tap will change from On to Auto to Off.

2 Likes

Very nice; simpler than three input booleans and a good use of the recently introduced cycle option.

1 Like

Please can you share how you did this?

I need a three state button, auto-man-off, in picture elements card but an input select doesn’t display very nicely.

What if you create an input number with min 1 and max 3 as a slider.
What does that look like on a picture elements card.
You could just add a sensor to translate 1 → manual and so on.

I settled on this:

  - type: image
    entity: input_select.drum_mode
    tap_action:
      action: call-service
      service: input_select.select_next
      target:
        entity_id: input_select.drum_mode
    image: /local/images/pond_control/off_button.png?v=3
    style:
      left: 37.7%
      top: 15%
      width: 4%
    state_image:
      'On': /local/images/pond_control/on_button.png?v=3
      'Off': /local/images/pond_control/off_button.png?v=2
      Auto: /local/images/pond_control/auto_button.png?v=2

Works very well. I then use the input_select state in automations without showing it in the front end.
One button toggles to three states, effectively.

1 Like

I would like to add my 50 cents.

I use a combination of:

  • input_select helper (configured in UI)
  • A template sensor to select the icon
  • Lovelace tap to cycle through the select entitiy

the input select (don’t worry about any icons here)

.
the template sensor:

  - sensor:
      - name: "KWL Mode icon"
        state: >-
            {{states('input_select.kwl_mode')}}
        icon: >-
            {% if is_state("input_select.kwl_mode", "Auto") %}
              mdi:fan-auto
            {% elif  is_state("input_select.kwl_mode", "Schwach") %}
              mdi:fan-minus
            {% elif  is_state("input_select.kwl_mode", "Stark") %}
              mdi:fan-plus
            {% else %}
              mdi:fan-off
            {% endif %}
        unique_id: uuidTemplatesdffewesdsfsfaniocom

the state will be copied over from the input select, however the icons are selected here.

in the frontend the magic happens by showing the template sensor and cycling through the helper by a tap, the lovelace code:

type: glance
entities:
  - entity: sensor.kwl_mode_icon
    tap_action:
      action: call-service
      service: input_select.select_next
      data:
        cycle: true
      target:
        entity_id: input_select.kwl_mode

Cheers
Jan

2 Likes