Matrix-style configuration

Hello all,

Is there a way to configure home assistant via a “map” or “matrix”?

Many input conditions are binary (door open, motion, occupancy, switch up / down). Often, combinations of those map onto a state

111001001 → Scene 01

111101001 → Scene 02

etc.

What’s the simplest way to set up such a map?

Many thanks!

So you want to convert a whole lot of binary entities to an arbitrary longer number and then run automations based on that?

Not convert to a binary number as such, that was just for illustration. But yes, mapping a set of binary inputs to a set of defined outputs (likely scenes).

Basically, I am looking for a way to define conditions between inputs and outputs in a more compact way, rather than using too much Boolean logic.

Concretely, suppose I had these four automations:

If a changes or b changes:
If (a=off and b=off) then scene 0

If a changes or b changes:
If (a=on and b=off) then scene 1

If a changes or b changes:
If (a=off and b=on) then scene 2

If a changes or b changes:
If (a=on and b=on) then scene 3

Overall, for a larger set of inputs and scenes, this becomes unwieldy.

Instead I want to define a single action:

If a changes or b changes:
Collect all inputs a, b.

Array = ( 
(Scene 0, Scene 1),
(Scene 2, Scene 3)
)

Set scene to Array(a,b)

I suppose it would always call out to a shell script but I’m wondering whether these a simple way to do this using the web interface

Thanks!

alias: example
trigger:
  - platform: state
    entity_id:
      - input_boolean.b
      - input_boolean.a
condition: []
action:
  - service: scene.turn_on
    target:
      entity_id: >
        {% set b = states('input_boolean.b') | bool(false) | int(0) * 2 %}
        {% set a = states('input_boolean.a') | bool(false) | int(0) %}
        scene.scene_{{ b + a }}
1 Like