Dynamic battery level icon for hue sensor does not work

Hi,

I have been trying to get my Philips Hue battery level icon the same as the iPhone battery level icon, so the icon will change depending on the level.

I found this example:

# template for the Hue sensor battery
- platform: template
  sensors:
    hue_sensor_battery:
      friendly_name: 'Hue sensor battery'
      unit_of_measurement: '%'
      value_template: '{{ states.sensor.hue_motion_sensor.attributes.battery }}'
      icon_template: "{%- if states.sensor.hue_motion_sensor.state >= '95' %}mdi:battery{%- elif states.sensor.hue_motion_sensor.state == '100' %}mdi:battery{%- elif states.sensor.hue_motion_sensor.state <= '15' %}mdi:battery-outline{% else %}mdi:battery-{{(states.sensor.hue_motion_sensor.state|float / 10)|round*10}}{%- endif %}"

It does does display a full battery, but changing the percentage to 20% manually does not change the icon.

That’s because you are presumably changing the state in dev-tools states? This won’t change the hardware so won’t affect the sensor.

Is there any other way to test this except for draining the battery? :wink: