Display % to the 7 LED

Hi,

I have currently few blue switchs using Home Assisants (ZHA) and using the 7 LED, I’m trying to display the % of a device ex:

0%-14%: Only the first LED lights up.
15%-28%: The first two LEDs light up.
29%-42%: The first three LEDs light up.
43%-57%: The first four LEDs light up.
58%-71%: The first five LEDs light up.
72%-85%: The first six LEDs light up.
86%-100%: All 7 LEDs light up.

But all the codes that I’m trying is not working.

Home assistant as modified it a little but here’s the code

alias: zzBattery Level on Inovelli LED Bar
description: ""
triggers:
  - entity_id: sensor.XXXXXXXXXXXX
    trigger: state

actions:
  - data:
      ieee: XX:XX:XX:XX:XX:XX:XX:XX
      endpoint_id: 1
      cluster_type: out
      cluster_id: 64561
      command: set_notification
      command_type: client
      args:
        - >
          {% set level =
          states('sensor.XXXXXXXXXXXX') | int
          %} {% if level <= 14 %}
            1
          {% elif level <= 28 %}
            3
          {% elif level <= 42 %}
            7
          {% elif level <= 57 %}
            15
          {% elif level <= 71 %}
            31
          {% elif level <= 85 %}
            63
          {% else %}
            127
          {% endif %}
        - 85
        - 1
        - 5
        - 255
    action: zha.issue_zigbee_cluster_command```