Read back brightness does not work in it condition

Hi.
I have some Ikea tradfri bulbs. It seems to me, the read back of the brightness is wrong only in if-conditions.

When I set the brightness to 50%, the device info also shows 50%. But when I want to test if it has below 90, the condition does not meet. I have to test against 150.

Example of a “3 step dimmer” with one button. The button shall simply toggle between off, 50%, 100%.

This is the automatisation which works after try and error. But I don’t understand why I cannot test for “brightness below 90” after I set the brightness to 50%

> alias: Wohnzimmerlampe ein.aus
> description: ""
> triggers:
>   - device_id: c5350b333eeb34791e1d6576308a6d3f
>     domain: zha
>     type: remote_button_short_press
>     subtype: turn_on
>     trigger: device
> conditions: []
> actions:
>   - if:
>       - condition: device
>         type: is_off
>         device_id: e25b846e1f75d3fe817900b53ac0086d
>         entity_id: 43f726e252a4505bd3e7e04c902c47d6
>         domain: light
>         enabled: true
>     then:
>       - action: light.turn_on
>         metadata: {}
>         data:
>           brightness_pct: 50
>         target:
>           device_id:
>             - e25b846e1f75d3fe817900b53ac0086d
>             - 907a1b2a368018b80ab80ba3bb67dfc8
>             - 2e7f22c1c0d8dafe01d92b362f2199b1
>     else:
>       - if:
>           - condition: numeric_state
>             entity_id: light.deckenlampe_1_leuchte
>             attribute: brightness
>             below: 150
>             above: 1
>         then:
>           - action: light.turn_on
>             metadata: {}
>             data:
>               brightness_pct: 100
>             target:
>               device_id:
>                 - e25b846e1f75d3fe817900b53ac0086d
>                 - 907a1b2a368018b80ab80ba3bb67dfc8
>                 - 2e7f22c1c0d8dafe01d92b362f2199b1
>         else:
>           - action: light.turn_off
>             metadata: {}
>             data: {}
>             target:
>               device_id:
>                 - e25b846e1f75d3fe817900b53ac0086d
>                 - 907a1b2a368018b80ab80ba3bb67dfc8
>                 - 2e7f22c1c0d8dafe01d92b362f2199b1
> mode: single

Brightness as an attribute is stored as 0 - 255, so 127 would be 50% brightness. Brightness percent is an action that converts 0 - 100% to a value between 0 and 255.

1 Like