Select by unit_of_measurement

Hi,

I’m using this code to enumerate some powersensors.

{% if 'power' in (state.entity_id | string).lower() %}'  {% if (state.state | float(2)) > 0 %}
  {{(state.attributes.device_class| string)}}={{ state.entity_id }}={{ state.state }},
  {% endif %}
 {% endif %}
{% endfor %}

How should I do to enumerate all sensors where “unit_of_measurement” like “W”.

Best regards
Magnus