I’m trying to create a group/sensor that will list all the devices that are home and another group/sensor that show all the devices NOT home… then display those two on the dashboard.
The way I decided to do this is to create a sensor that loops through all the states in device_trackers and lists the ones that are home. The problem I get is that the result is more than 255 characters and i get an error because they all do not fit in a sensor. See here:
- platform: template
sensors:
devices_home:
friendly_name: "Devices Home"
value_template: >-
{% for state in states.device_tracker -%}
{% if state.state_with_unit == "home" -%}
{{state.name}}
{% endif %}
{%- endfor %}
devices_away:
friendly_name: "Devices Away"
value_template: >-
{% for state in states.device_tracker -%}
{% if state.state_with_unit != "home" -%}
{{state.name}} ({{state.state_with_unit}})
{% endif %}
{%- endfor %}
Is there another way to do this by grouping sensors that belong to a specific state?
-------------------------EDIT-------------------------
Now that I think about it some more, I realize this may not be possible because group items are rendered on restart so you can’t have sensors dynamically jump from one group to another.
I think my only option may be to narrow down the criteria for which devices I watch to track that are home (or not home).