Inconsistent UI behavior with template

I’ve run into a problem with a group of two bulbs and how brightness is reported. I have a template that converts to brightness of the group to the range 0-100. But, when the bulbs are on at 100%, clicking the group in the UI displays 258%, while the UI itself displays 100%.


Here is my template:

       {% if (states('light.bedroom_fan_bulb') == 'on') %}
            {% if ( state_attr('light.bedroom_fan_bulb', 'brightness') | float(default=0) >= 258 ) %}
                Brightness: 100%
            {% else %}
                Brightness: {{(state_attr('light.bedroom_fan_bulb', 'brightness') | float(default=0) * 0.386) | round(0, 'ceil', default=0) }}%
            {% endif %}
        {% endif %}

How can I fix this?
Thanks

The brightness integer range is 0 to 255, not 258.

You need to limit your template output to that range.

Thanks for the reply, but I tried your suggestion, but still get the same result:


       {% if (states('light.bedroom_fan_bulb') == 'on') %}
            {% if ( state_attr('light.bedroom_fan_bulb', 'brightness') | float(default=0) >= 255 ) %}
                Brightness: 100%
            {% else %}
                Brightness: {{(state_attr('light.bedroom_fan_bulb', 'brightness') | float(default=0) * 0.388) | round(0, 'ceil', default=0) }}%
            {% endif %}
        {% endif %}

What card is this that accepts templates?

It doesn’t look like your template is changing the brightness. (It looks like it is just converting it for display.) Is that set somewhere else?
-David

It a secondary info card.

It’s not supposed to change the brightness. It only converts the brightness value, which is in the range 0-255, to 0-100.

Why do you think changing the brightness display in the secondary info card would change the display in the more info pop-up?

The more info pop-up gets its information from the entity, not from the secondary info card.

If you want to scale the brightness everywhere you need to create a new template light from your existing light.

Ah! I get it now, but what do you mean by “…create a new template light from your existing light…”?
Do yo mean a light group that wraps the actual group?
Something like this:

base group:
- platform: group
  name: "Bedroom Fan Bulb"
  entities:
    - light.fan_bulb_1
    - light.fan_bulb_2

wrapper:
- platform: group
  name: "Fan Group"
  entities:
    - light.bedroom_fan_bulb

If so, I get the same result. The main group reports 657 as brightness and the same is reported as brightness for the wrapper:

supported_color_modes:
  - brightness
entity_id:
  - light.fan_bulb_1
  - light.fan_bulb_2
icon: mdi:lightbulb-group
friendly_name: Bedroom Fan Bulb
supported_features: 32
color_mode: brightness
brightness: 657

Thanks

Copy your existing light state and controls into this:

And scale the brightness template as you need.

Use the entity it creates in your dashboard instead of the original light.