Help with a toggle button matrix please

Hi all,

I'm recovering from knee surgery so what better time to mess with my Home Assistant & Node Red code :slight_smile: So far I have completely rebuilt my HA dashboard and now looking at being smart with the media control but it's fighting back LOL

On my HA dashboard I have 4 buttons (input boolean helper entities) - these control my Sky box, my Plex media player plus two custom ones for Sky news direct and my partners exercise video direct.

I am struggling with odd behaviour because in my NR code, when the Sky button is pressed, I turn off all other buttons otherwise they will stay on - the user does not press "Sky off" followed by "Plex on", they simply go direct for "Plex on" even though Sky was already on.

However, when i set the toggle to off in NR it also triggers the action associated with that button in the dashboard - this is causing things to turn off and on multiple times and totally not wanted.

Is it because I chose input.boolean helpers and not input.button maybe?

Is there a sensible way to have a button control matrix like this - it also ties in with Alexa so if i ask Alexa to turn Sky on, it also turns on the dashboard button respectively.

All good fun, thanks for any help :slight_smile:

Well, i've changed to input.button entities, this makes it work but i lose the visual on/off display that the input.boolean option gives.

The code is simpler as there is no need to turn the unused buttons off as they don't show as on. However, to get an "off" control now needs an off button as they are no longer toggles.

Swings and roundabouts i guess :upside_down_face:

Create a trigger template sensor that will show the last button pressed.

template:
  - triggers:
      - trigger: button.pressed
        target:
          entity_id: input_button.a
        id: button_a
      - trigger: button.pressed
        target:
          entity_id: input_button.b
        id: button_b
      - trigger: button.pressed
        target:
          entity_id: input_button.c
        id: button_c
    sensor:
      - name: "Button Event Tracker"
        unique_id: button_event_tracker
        state: >
          {% if trigger.id == 'button_a' %}
            Button A
          {% elif trigger.id == 'button_b' %}
            Button B
          {% elif trigger.id == 'button_c' %}
            Button C
          {% else %}
            {{ states('sensor.button_event_tracker') }}
          {% endif %}

Then use a card like the custom button card that can be set to change color depending on the state of the above entity.

Interesting, thanks

I'll look into how that all works as i have only ever used one template before lol

If you already have a template: entry in configuration.yaml, it only needs to be there once, not for each sensor.

I also made a mistake above, the trigger is button.pressed not button.press.

My mistake: I have only used an automation once, never used a template so no entry in config.yaml

:slight_smile: