Is it possible to get the unique_id of an entity in the template editor?
I’m able to iterate over the entities of a specific device with
{% set device_name = 'test_dev' %}
{% set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
{% for device in devices if device_attr(device, 'name') is not none and device_attr(device, 'name') in device_name %}
{% set entities = device_entities(device) | list | sort %}
{% for entity in entities %}
{#{ print unique_id of entity }#}
{% endfor %}
{% endfor %}
but I have no idea how to get the unique_ids, which I would need.
First … why do you think you ‘need’ the unique_id of an entity.
Second … my testing of the above does not print object_id or device name, followed by an underscore, followed by the entity name. I only get the entity_id. ie: cover.big_garage_door or light.ratgdov25i_eeef35_light.
I’m working on GitHub - pikim/tomato-mqtt. These are a couple of scripts on my router that send data to Mosquitto. They support device discovery and I want to send the discovery message only if an entity wasn’t registered, yet. I’m using a twig template to query the existing entities of the according router device and also some state and meta information. For this I’d like to get the unique_id as the entity name and object_id can be changed by the user. So it seems difficult to use those.