Trying to create a template sensor for updates, but I could’t figure out how to add the title/friendly name at the end instead of the entity_id together with the available version number. This is what I have now:
{% set update_available = namespace(entities=[]) %}
{% set entities = ['update.deconz_update', 'update.home_assistant_core_update']
%}
{% for item in entities %}
{% if states[item].state == 'on' %}
{% set update_available.entities = update_available.entities + [item] %}
{% endif %}
{% endfor %}
{{ update_available.entities }}
Attribute latest_version needs to be added, but also interested what to be done with [item] in the first example. Thanks for the suggestions in advance.
Thank you Didgeridrew, works like a charm. One last question, because I used 2 entities for the testing, how can I add the whole update domain to the entities without listing them one by one?
UPDATE: I was able to figure out the missing pieces based on yours:
{% set entities = states.update| list %}
{% set update_available = namespace(entities=[]) %}
{% for item in entities %}
{% if item.state == 'on' %}
{% set update_available.entities = update_available.entities + [item.attributes.friendly_name ~' - '~ item.attributes.latest_version] %}
{% endif %}
{% endfor %}
{{ update_available.entities | join(',\n') if update_available.entities | length > 0 else 'none' }}
@Didgeridrew: the formatting of the list is discarded on the property screen of the entity, so I would like to replace the comma and line break separated list with an enumetation. What should be used instrad of (’, \n’) in this case? Thanks in advance.
Sorry, my explanation was not clear. I would like to have something similar to the sensor.hacs, but with less entries (diplay name and available version) and beside HACS, the HA/add-on updates too: