I have a sonoff nspanel with tasmota and I want to dim smart bulbs by holding (long press) the physical buttons. The buttons have been decoupled from the relays so they just send commands; but when using the following automation l, the lights end up in a continuous loop. Any ideas on how to fix the automation please?
The trigger.id will always be the same. So your automation will always enter an endless loop because of your while statement. If your device has a âreleased the buttonâ trigger, then youâd want to use that for your while loop. Otherwise it will always be a guessing game.
You appear to only have one command to signal the start of the dimming process. Without a second one to stop it, it will behave the way you have already observed (loops forever).
no, because the system wonât know when to stop. Iâd be willing to bet there is a way to detect it but only you will be able to find out how because you have the device. Events arenât easy to work with. Does your device have an event entity?
I have no experience with nspanel running Tasmota but I found this documentation:
It contains a screenshot showing button events (linked below). What I donât see in the screenshot is a button event indicating when a button is released.
I donât know if itâs displaying all available button events but, for your application, you need an event to indicate when the button is no longer being pressed. Without that, I donât see how itâs possible to achieve your goal practically.
I say âpracticallyâ because you could use a double-press to signal the end of a long-press but that would be an unusual way to control fading; the usual way is to simply release a button to stop fading, not double-click it.
Your application really needs a button-release event.
I found another screenshot that lists button events and it also lacks a release event.
You can confirm it for yourself by creating an automation with a Device Trigger for your nspanel device. It will display a list of available button events. If it looks like either of the two screenshots I posted, then thereâs no release event.
I searched for examples of what you are trying to do (with the nspanelâs buttons) and couldnât find any. At best, other people use them to initiate something (turn on a light, etc) because you only need one button event to do that.
Without knowing when a button is released, the alternative is to use some other button event. However, as explained above, it creates an unusual (unintuitive) way of controlling fading behavior (i.e. press once to start fading, press twice to stop it or long-press to start and short-press to stop ⌠either way is non-standard).