immersive-home/app/lib/home_apis/hass_ws/templates/devices.j2

23 lines
1003 B
Plaintext
Raw Normal View History

2023-10-30 02:21:50 +02:00
{% set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
2023-12-09 23:50:23 +02:00
2024-05-06 13:42:45 +03:00
{%- set ns = namespace(devices = [], entities = []) %}
2023-10-30 02:21:50 +02:00
{%- for device in devices %}
{%- set entities = device_entities(device) | list %}
2024-05-06 13:42:45 +03:00
{%- set ns.entities = [] %}
2023-10-30 02:21:50 +02:00
{%- if entities %}
2024-05-06 13:42:45 +03:00
{%- for entity in entities %}
{%- set ns.entities = ns.entities + [ {"id": entity, "name": state_attr(entity, "friendly_name")} ] %}
{%- endfor %}
{%- set ns.devices = ns.devices + [{"id": device, "name": device_attr(device, "name"), "entities": ns.entities } ] %}
2023-10-30 02:21:50 +02:00
{%- endif %}
{%- endfor %}
2023-12-09 23:50:23 +02:00
{%- set ns_group = namespace(entities = []) %}
{%- for state in states %}
{%- if device_id(state.entity_id) == None %}
2024-05-06 13:42:45 +03:00
{%- set ns_group.entities = ns_group.entities + [{"id": state.entity_id, "name": state.entity_id}] %}
2023-12-09 23:50:23 +02:00
{%- endif %}
{%- endfor %}
2024-05-06 13:42:45 +03:00
{%- set ns.devices = ns.devices + [ {"id": "other.other", "name": "Other", "entities": ns_group.entities } ] %}
2023-12-09 23:50:23 +02:00
2023-11-05 17:36:13 +02:00
{{ ns.devices }}