How to make a card visible only if a light brightness in below 100%?

So I want a button on a bubble card (they are from hacs) that set a light brightness to a 100% and I want this button to only appear if the light brightness is below 100%. I failed to do that so I tried with a regular Button Card, this is what I’ve come up with:

condition: numeric_state
entity: light.yeelink_bslamp2_ac48_light
attribute: brightness
below: 100

I tried different lights, different values, nothing works.


The light is currently at 25% when taking this screenshot.
I’ve read many forum topics at this point and nothing works, please help me.

Are you sure your brightness is in %, not a value between 0 and 255?

Check in the Developer Tool - States

It is in % (it is set at 42% as I am taking the screenshot):


I also tried to use light.brightness as the attribute instead of just brightness but it doesn’t work either.

Your screenshot shows 2 ‘brightness’ attributes:

I seriously doubt that this one is in %:
image

And this one is not really called ‘brightness’ as shown in you YAML sample:
image

But if you multiply 255 x 42% the result is …drum roll please… 107.1

So 107.1 is NOT below the threshold you have here:

I missed there was a second brightness attribute, but… drum roll pls… I can set the below value to 100, 255, 1000, or whatever and it still never works.

Works fine for me with brightness set to 49% in the frontend:

Try to replace entity with enttity_id

If I change to entity_id I cannot test because I get the following error message:


This is very odd considering it is working for you. I double checked for typos (you got one in the last line of your post) but there are none.
My home assistant versions are:

  • Core 2025.2.4
  • Supervisor 2025.02.1
  • Operating System 14.2
  • Frontend 20250214.0

I think I have the latest, so maybe you have an older version and they stopped supporting the entity_id property, or something is wrong with my ha.

This is THE way you reference entities in HA.

No. Something else is wrong chair is not incorrect with thier analysis…

The config with entity doesn’t cause an error (just it does not pass when it should):
https://imgur.com/3xNHzzc
The one with entity_id:
https://imgur.com/iC22q4S
Causes an error:


The id is correct btw:
There should be an image of the entity here, but as a new user I am limited to 2 links and 1 media :frowning:

I concur that something must be wrong, however I’m new to home assistant and even with google I cannot figure it out. So any help is greatly appreciated.

Here’s the last & final idea I have:
Create a template sensor from the attribute and use the state of the sensor to manage visibility.

1 Like

The sensor solution works perfectly, here is the sensor:

binary_sensor:
  - platform: template
    sensors:
      bedside_lamp_100:
        friendly_name: "Bedside Lamp 100% Brightness"
        value_template: >-
          {{ 
            is_state('light.yeelink_bslamp2_ac48_light', 'on') 
            and 
            state_attr('light.yeelink_bslamp2_ac48_light', 'brightness') == 255
          }}

However it means I have to make a sensor for every light for which I want to make this conditional button, so if you have a solution to make the process easier or to fix the issue without using the sensor I am interested.

In the meantime this solution will work, thanks for your help.