I am using the following code from a blueprint to turn and dim a light.
Right now, I am using a very clumsy if condition to turn the light back on to 10% if you dim too far that the light turns off. I am trying to introduce a variable that can be checked instead so that the light does not turn off and then back on but am learning yaml as I go an unsure how to add it to the automation.
How do i extend the code in the Down_HoldPress section to stop the lamp turning off and always be on at 10%?
This sort of works as it stops the lamp turning off but it doesn’t allow me to set the dimness of the lamp as it just sets the minimum threshold when I press the dim down button. I’d like to be able to dim the lamp still if it’s at maximum brightness and just avoid the lamp turning off by overshooting.
So, why don’t you save your time by testing the light manually in order to find its minimum brightness and then hard-code it?
You probably can still do it programmatically, but that will provide some bad experience to the user as the light will go off before the system can detecte it happening and be able to turn on back, reduce the step and try again with a smaller step, in a kind of a loop until it finds the minimum every time (or at least the first time and then stores the minimum in a helper, which will be even more work for you).
I see what my problem is now and why setting “brightness value” wasn’t working for me before. I have to set a min value of at least 25 as this is 10% of 255. It’s a bit confusing because the device brightness slider is between 0 and 100, so presumably this is it’s percentage value and not it’s step value.