Battery icon with question mark why? dynamic icon is not working :-(

Hi
ich have a problem with the MQTT Signal of my mower. i get the SOC of the battery via MQTT with this topic:

gardena/mower/battery/charge

The sensor.yaml looks like this:

- platform: mqtt
  state_topic: "gardena/mower/battery/charge"
  name: "gardena r70li battery"

then i customized it like this in customize.yaml

sensor.gardena_r70li_battery:
  friendly_name: Batterie SOC
  device_class: battery

But in Lovelace i don t get the dynamic icon.


what is wrong?

Remove the customisation and put the device class directly in the sensor.

- platform: mqtt
  state_topic: "gardena/mower/battery/charge"
  name: "gardena r70li battery"
  device_class: battery

If that does not work, check the developer tools states menu to see if the % symbol is included in the state. If it is you will have to remove it with a template in your mqtt binary sensor.

hi @tom_l
i put the device_class already in the sensor.yaml, same problem.
the “%” is included in the state. how do i remove it with a template?

Thanks @tom_l

got it to work

- platform: mqtt
  state_topic: "gardena/mower/battery/charge"
  name: "gardena r70li battery"
  value_template: "{{ value.replace('%', '') }}"
  unit_of_measurement: '%'
  device_class: battery
2 Likes