I can see my lights have a great feature, to use a effect, in the Z2M module, if i activate an effect, the light executes the effect. regardles of whether it is off or on, it executes the effect and goes back to the previous state.
Keeping the state while activating an effect is not possible, and does also not seem to be what you want (if the light is off, how would you see the effect without the light turning on?).
If you want to return to the previous state after the effect is done, you can create a scene on the fly and restore it afterward. That way you do not need to know what the state was, it will simply go back to that state.
You can use scene.create with entities to take a snapshot of, and scene.turn_on to use that scene to go back to that state.
To me, it would not make sense that if I activate an effect, the light should stay off, or go off again on its own after some time by default.
Activating the effect in Z2M does just that though, just do the effect and then turn back off. So yeah, if i call the blink effect i want my light to blink, not turn on…
And on the fly scenes are major overkill, for the default effects present in my lights:
If the light is already on, and i call the turn_on with only the effect, then it works fine.
If the light is off, i have to call the off after the effect is finished.
But this is always a bit finiky and leaves the light being on for a little bit after the effect. and that feels dirty compared to the clean call of the effect i can do from the Z2M screen.
just encountered the same issue of simply wanting the light to perform the effect and then return to it’s previous state as smooth as it is possible via Z2M.
Solution: Bypass the HA ‘light.turn_on’ action and directly use MQTT:
Some thoughts:
This works fine for single action effects, e.g. okay or blink.
If you would use breathe and want to cut it short - because you want the light to take just one breath instead of 15 - you would need to send a finish_effect after a short timeout - which most likely will introduce some jankyness.