-
-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Which Blueprint is This Concern About / Related To?
dimmer_control_4_magic_cube.yaml
Is your feature request related to a problem? Please describe.
When using the dimmer script in conjuntion with an aqara H2 dimmer switch with a custom quirk I noticed there was an error that it would throw when maxing the brightness out, either it would be a number past 100% or it would already be set to 100% and trying to up the brightness I would see an error thrown for attempting to up the brightness, this causes no issues with functionality but if you've got a buggy mess of a home assistant installed or are trying to develop multiple different things less logs that look like problems are a good thing.
Describe the solution you'd like
I have adjusted my own script like so and it seems to work, I've list no functionality and I no longer see the errors when trying to adjust over 100%.
bright_p: >-
{% set step_size = angle * sens_d %}
{# Get brightness as a percent. #}
{% set cb = (state_attr( light, 'brightness') | float(10) / 255.0) * 100.0 %}
{% set new_brightness = cb | int(10) + step_size %}
{% if new_brightness > 100 %}
{# If it's over 100, set to 100. #}
100
{% elif new_brightness < 5 %}
{# If it gets really low set to 0. #}
0
{% elif new_brightness <= min_b_var %}
{# If it's not quite 0, set to a minimum working brightness. #}
{{ min_b_var }}
{% else %}
{# Send actual calculated value. #}
{{ new_brightness | int }}
{% endif %}
Describe alternatives you've considered
Alternatively, it could just be left as is since it doesn't actually change the function of the script, just quites down the errors a bit.
Additional context
Added some images of the errors that I saw as a result.


