Grouping - several sensors with enum options

tl;dr - How to set a sensor grouping’s class as enum, then list the potential values as its options.

Hi there. I’m at the start of my HA journey and I’m not sure what I’m after is possible but I wanted to check with anyone more knowledgeable than me.

I’ve managed to do pretty well and get my car into HA and it has an sensor entity for each tire - which returns one of five values - UNSPECIFIED, NO_WARNING, VERY_LOW_PRESSURE, LOW_PRESSURE, HIGH_PRESSURE.

I am trying to create a group which would group all tires, and when any one of them flags a warning, then the group would show the relevant warning value for the whole group, otherwise, as the vast majority of the time there would be NO_WARNING, it would just state that (or some other representative value like “OK”, “Clear”, “Fine”, etc).

I have done this for my car doors and windows, as there is a ‘locks’ option in groups, but the tires don’t return a binary option. From a bit of reading it looks like the way to go might be to set the group as a sensor and in the sensor’s options set the class as enum, and then list the values the tires return in the options.

However I don’t know how to do this, can’t seem to find an example of any code I can copy and experiment with (how I’ve been learning so far) where someone has tried anything similar, and even if there is some way to do this, whether the group will work in the way I want - showing the warning value for the whole group if any of the sensors return a warning.

Has anyone achieved anything similar to this, or has good experience with the enum class who can advise? Hopeful thanks in advance.

Template sensor?

template:
  - sensor:
      - name: Tire group status
        icon: mdi:car-tire-alert
        state: >
          {% set sl = [states('sensor.car_fl_tire'),
                       states('sensor.car_fr_tire'),
                       states('sensor.car_rl_tire'),
                       states('sensor.car_rr_tire')] %}
          {{ sl|reject('eq','NO_WARNING')|first|default('OK') }}
1 Like

Finally got a moment to try this and it was perfect! Thank you for the guidance - I’ve used this in several other places now too! Thanks again!

1 Like