Change view icon in lovelace with battery level

Hi, I’m trying to change an icon in the view panel… I have a view named “battery” that shows the level battery of a tablet (sensor works fine)

ui-lovelace.yaml

  - title: battery
    icon: mdi:battery
    id: battery_level
      cards:
       - type: gauge
         title: Livello Tablet
         entity: sensor.display_tablet_battery
         min: 0
         max: 100
         severity:
           red: 0
           yellow: 20
           green: 60

configuration.yaml:

customize:
  group.battery:
    templates:
      icon: >
        if (entities['sensor.display_tablet_battery'].state < '20') return 'mdi:alert-decagram';
        return 'mdi:battery';

But it doesn’t work… any suggestion?

PS: edited, sorry guys…

You have to change the icon in ui-lovelace.yaml

wherever you put the entity, you have to do it like this

- entity: group.battery
  icon: mdi:battery

Ops I made a little bit of confusion, I was thinking at two different things and mixed them together :sweat_smile:
In my previous post the first code block is ui-lovelace.yaml, not groups.yaml… so I’m trying to set the view icon depending from the battery sensor state/level… if sensor state/level is x then view icon = A else view icon = B

so what interface are you using? CustomUI or Lovelace. Things that change in custom UI will not affect lovelace.