Template to List the name and state of all sensors in a group

I want to create an iOS action to receive a notification that contains a list of names and states of all sensors in a group.

I know how to create the notification with the template to list the names OR the states but I can’t list them together.

Anyone any idea how to realize this?

2 Likes

The basic method is to use a for loop…

{% for x in expand('sensor.YOUR_SENSORS')|
map(attribute='entity_id')| list %}
{{state_attr(x,'friendly_name')}}: {{states(x)}}
{% endfor %}

or

{% for name, state in expand('group.YOUR_SENSORS') | groupby("name") %}
  {{- name }}: {% for sensor in state %}
      {{- sensor.state }}
    {% endfor %}
{% endfor %}
1 Like

Thanks a lot Didgeridrew, it works perfectly :ok_hand:

Ty! Its possible to show the Entity with the lowest “state” now to hide the rest!?

{% set sensors = expand('group.YOUR_SENSOR_GROUP') %}
{% set lowest = sensors | selectattr('state', 'is_number') | map(attribute='state') | map('float') | list | min %}
{% set low_sensor = sensors | selectattr('state','eq', lowest | string) | first %}
{{ low_sensor.name }}: {{ lowest }}
2 Likes