thomasloven / lovelace-template-entity-row

🔹 Display whatever you want in an entities card row.
MIT License
210 stars 16 forks source link

Icon when device_class: battery #8

Closed pmazz closed 4 years ago

pmazz commented 4 years ago

Hi Thomas, thank you for this great card!

I've found a small issue related to icon when sensor has device_class attribute.

Given my sensor:

- platform: mqtt
  name: cell_paolo_battery
  unit_of_measurement: "%"
  device_class: battery
  state_topic: ...
  value_template: ...

And my lovelace:

- entity: sensor.cell_paolo_battery
  name: Paolo's Phone (standard)
- entity: sensor.cell_paolo_battery
  type: custom:template-entity-row
  name: Paolo's Phone (t-e-r)
  icon: "{{state_attr('sensor.cell_paolo_battery', 'icon')}}"
  state: "{{states('sensor.cell_paolo_battery')}} {{state_attr('sensor.cell_paolo_battery', 'unit_of_measurement')}}"

The result is: image

As you know the device_class: battery attribute shows the icon which properly represents the current battery level. It seems the card is not able to get the icon.

pmazz commented 4 years ago

I've edited the issue because realized that I didn't referred the icon properly. But the issue seems still there...