UPDATE: I think I figured out how the automation works; single transition (transition time being in tenths of a second) and is âcancelledâ by the release of the button. However I am still looking for a way to have a lower threshold. My guess would be something along the lines of a calculation which passes âthe current brightness level minus the minimum thresholdâ as the bri_inc value in the âdim downâ option. But my scripting skills are not good enough to get it right just yet. Can anyone help out? My dimmers also have a physical button for setting the minimum level, but preferably I would like it to be part of the automation to avoid being dependent on physical access to the device (which are typically in the wall/ceiling in my house).
UPDATE2: I figured out how to set the minimum level by using a template in the âdim downâ option. Something along these lines:
bri_inc: >
{{ 50 - state_attr('light.light_source', 'brightness') | int }}
where 50 is my minimum level.
Original comment
This is great! Thanks for sharing. I have it working nicely with an IKEA Tradfri on/off switch.
However, I do have one wish, which I donât have enough experience with automations/scripting to accomplish: When dimming down the lights, I would like it not to completely turn off my light, but have a configurable lower boundary which the automation will not go below, even if I keep the button pressed.
I have tried playing with the bri_inc value in the âdim downâ option, but cannot seem to get it right. I might also need a bit of clarification about how this actually works.
As I understand it, the âdim downâ condition is only hit once (when I press the switch down and hold it). And as such, I assumed that would start a brightness decrease with value -254 (as per the OP) with a transition time of 50 (ms?). Since the dimming definitely happens a lot slower than 50ms, I assumed it works by initializing a dimming process which dims in steps of -254 every 50ms thus resulting in a (relatively) smooth dim down operation. However, when I inspect the state of the light, I can see that it has a brightness value of 254 when brightest, and 0 when dimmed all the way down (i.e. to âoffâ).
So I cannot really understand how the automation works. Can someone please explain to me how it works?
Regarding having a lower limit, I can add a condition to the âdim downâ option to only execute if the current brightness level is above a specific value, however, this only prevents the âdim downâ option from executing if the brightness is below the condition value when the button is pressed (i.e. nothing happens), but if the brightness is above the condition value, then it dims all the way down. So I would love some guidance on how to achieve a lower boundary on the âdim downâ option.
As mentioned I am using the IKEA Tradfri on/off switch, and therefore long-pressing the switch only produces one event when long press is detected, and another event when the switch is released (as opposed to continuous events while keeping it pressed).