Tricky (auto entities?) template question

I have a bunch of ESPHome devices with wifi signal strength sensors with entity id’s like this:


The common thread being sensor.*_wifi_signal

I manually grouped bar card graphs of them by SSID (== WAP ID essentially) and all was good:

This would quickly tell me if I had an issue with a sensor or access point.

Then I discovered I could specify more than one SSID in ESPHome and it would pick the strongest signal to connect to. I created a sensor for each device that reports the SSID it is connected to, the entity ids are the same as above but with wifi_signal replaced with ssid, e.g.


The common thread being sensor.*_ssid and * is the same string as the signal strength sensors.

As the two types of sensors are independent I can’t think of a way to automatically group the bar graphs of signal strength by SSID with the auto-entities template-able “include” option.

I could create template sensors that copy the signal strength for each device and add the SSID as an attribute. But that seems like a lot of work (45 signal strength sensors).

Any ideas?

I don’t get what you’re asking. You want to find both *_wifi_signal & *_ssid?

or you want to use what’s in the * to find the matching _ssid?

I want to group the signal strength sensors by the ssid they are connected to.

If sensor.name_abc_ssid == ‘WAP1’ then select the sensor sensor.name_abc_wifi_signal for the WAP1 card.

Likewise for the other 44 signal sensors and 4 distinct SSIDs (so 4 cards).

Sounds like you can just use the template filter, but you’ll have to list all sensor.*_ssid’s in the entity_id field.

  template: >
    {%- set ssid = 'WAP1' %}
    {%- for object_id in states.sensor | selectattr('state','eq', ssid) | map(attribute='object_id') %}
       sensor.{{ object_id.replace('_ssid','') }}_wifi_signal{{ '' if loop.last else ', ' }}
    {%- endfor %}
  - list
  - all
  - sensor.*_ssid

So I cant just use the wildcard sensor.*_ssid in the entity_id list?


I have to list them all individually?

It doesn’t look like it from what I can tell. The problem is, you’d need to build the wildcard list, then a second list based on the first. And the second list based on the first is where your problems arise.

1 Like