Input Select with Radio Buttons and Exclusive OR Logic

I have a Sonoff 4CH PRO flashed with the Tasmota firmware. I am going to use this to replace the controls of a shop air filtration system (AFS). That AFS has a control for 3 fan speeds (low, medium, high). For those of you who are familiar with the Sonoff 4CH units you know that there is a interlock mode which only allows 1 relay to be active at a time. My end goal is create a similar situation in HA but I want to be able to use the 4 channel for something else so I can’t just rely on the unit’s interlock mode.

I’ve created an input select:

afs_speed:
  #name: Jet AFS Speed
  options:
    - "NotON"
    - "LOW"
    - "MEDIUM"
    - "HIGH"
  icon: mdi:fan
  initial: NotON

But this interface create a drop down menu but I’d rather make the interface be radio buttons so it’s 1 press to set the fan speed rather than press to bring up the drop down menu and then another press to select what mode you want.

I think that’s the easy part of my question. My harder part is learning how to create the logic that handles this “exclusive or” situation and then passes it off to the switch. I think this is going to involve scripts and automation which I haven’t tackled yet so I’m looking for pushes in the right direction.

BTW, on the input select when I used "OFF" as one of my options and set that as the initial condition (initial: OFF) I would get an error when I checked my configuration. I think HA was trying to interpret the OFF as a false condition?

Thanks in advance!

Good luck! I had to do this with a device in the past. While it’s possible, it takes a lot of yaml.

If i remember correctly, I needed:

1 input_boolean, 3 automations (on automation, off automation, update automation) per ‘radio’ button.

In addition, i needed:

1 automation for ‘powering off everything’, 1 sensor to determine if any radio buttons are on, 1 sensor for the current state (this might be redundant, I may have used this to decrease the amount of yaml in other areas).

So, for you, if you had 3 choices, you would need 3 input_booleans, 10 automations, and 2 sensor to make ‘radio buttons’.

Here’s all my crap, I had 2 on sequences depending on the time of day:

sensors (platform: template):

  harmony_activity:
    value_template: >
      {% if is_state("remote.living_room", 'on') %}
        {{ states.remote.living_room.attributes.current_activity }}
      {% else %}
        PowerOff
      {% endif %}
    friendly_name: Harmony Status
  harmony_radio_buttons:
    value_template: >
      {% if 1 == 1 %}
        {% set n = 0 %}
        {% if states.input_boolean.xbox.state == "on" %}
          {% set n = n + 1 %}
        {% endif %}
        {% if states.input_boolean.playstation.state == "on" %}
          {% set n = n + 1 %}
        {% endif %}
        {% if states.input_boolean.wii_u.state == "on" %}
          {% set n = n + 1 %}
        {% endif %}
        {% if states.input_boolean.computer.state == "on" %}
          {% set n = n + 1 %}
        {% endif %}
        {% if states.input_boolean.switch.state == "on" %}
          {% set n = n + 1 %}
        {% endif %}
        {% if n > 0 %}
          on
        {% else %}
          off
        {% endif %}
      {% endif %}

Example Automations (has extra power on):

- alias: Update All Radios
  trigger: 
    platform: state
    entity_id: remote.living_room
  condition:
    condition: template
    value_template: >
      {% if trigger.to_state.attributes.current_activity == 'PowerOff' %}
        True
      {% else %}
        False
      {% endif %}
  action:
    service: script.turn_on
    entity_id: script.harmony_sequence_power_off

- alias: Computer On Night
  trigger:
    platform: state
    entity_id: input_boolean.computer
    from: 'off'
    to: 'on'
  condition:
    condition: state
    entity_id: sun.sun
    state: "below_horizon"
  action:
    service: script.turn_on
    entity_id: script.harmony_computer
  
- alias: Computer On Day
  trigger:
    platform: state
    entity_id: input_boolean.computer
    from: 'off'
    to: 'on'
  condition:
    condition: state
    entity_id: sun.sun
    state: "above_horizon"
  action:
    service: script.turn_on
    entity_id: script.harmony_sequence_computer
  
- alias: Computer Off
  trigger:
    platform: state
    entity_id: input_boolean.computer
    from: 'on'
    to: 'off'
  condition:
    condition: template
    value_template: "{{ states.sensor.harmony_radio_buttons.state == 'off' }}"
  action:
    service: remote.turn_on
    data:
      entity_id: remote.living_room
      activity: 'PowerOff'
      
- alias: Update Computer Radio
  trigger: 
    platform: state
    entity_id: remote.living_room
  condition:
    condition: template
    value_template: >
      {% if trigger.to_state.attributes.current_activity == 'PC' %}
        {% if states.input_boolean.computer.state == 'off' %}
          True
        {% else %}
          False
        {% endif %}
      {% else %}
        False
      {% endif %}
  action:
    service: input_boolean.turn_on
    entity_id: input_boolean.computer

OK, thanks for the details and direction to look into. I was thinking there wasn’t an “easy” way but I started thinking that if there isn’t there probably should be. Basically any fan control will have multiple speed selections and only 1 mode can be selected at a time which is what I’m trying to achieve. So it would be nice if there was a component that worked like this and you just fed it what inputs are the choices.

I guess even the inputs on your TV are the same (ignoring PiP). You have multiple choices but only 1 can be active at a time. Of course those units are usually more intelligent and you can just send them what input you want to choose but the basic idea is the same.

You may be able to make a slider that links to your input_select through indexes. It might be the simple approach.

The TV inputs had pitfalls, i assume you would run into them as well. Basically, if you switch between radio buttons too fast, HA puts the device into perpetual one->off->two->-off->one->off… So it’s still not perfect. I ended up switching to AppDaemon to handle it better, less lag and less chances to get into the perpetual loop. It would be better if they just came up with a radio button control.