I do not recommend using a Template Sensor for this application. I suggest you consider using a Markdown Card to display the list of entities instead of attempting to stuff them into a Template Sensor’s state value.
Copy-paste the following template into the Template Editor and confirm it reports the desired information.
{% set entities = states
| selectattr('attributes.device_class', 'defined')
| selectattr('attributes.state_class', 'defined')
| selectattr('attributes.device_class', 'eq', 'power')
| selectattr('attributes.state_class', 'eq', 'measurement')
| sort(attribute='name') | list -%}
{% for e in entities -%}
{{ e.name}} {{ e.state }} W
{% endfor %}
If it’s satisfactory, use the template in a Markdown card.
@123
wouv, you did not only solve my issue with finding all entities, you also solved my next issue, why it only shows some of the enteties and not all. I thought the truncate, was to make sure, that the lines would not become to long, had not understood, it was total lines.
Great thanks a lot, learned another good thing today
Marinus
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
You marked your own post with the Solution tag (again).
The purpose of the tag is to direct other users to instructions that solve the problem. That would be my post here which explains why you aren’t seeing all the data and provides with you with a solution.