Using light effects, without turning the lights on

Howdy,

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.

I cannot do this from home assistant, if i activate the effect here, the lights stays on.

In an automation i can fix this, when the light is on, you can just call the turn on with the blink effect, no problem:

service: light.turn_on
metadata: {}
data:
  effect: blink
target:
  entity_id: light.0_wer_lmp_plafond

And when it is off to start with, call the same service and 500ms later call the turn off scene. though this also feels dirty to me.

Am i missing something here?

Is there a way to trigger the effect without changing the state of the light in HA?

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.

Hey @Floppymonster ,

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:

- action: mqtt.publish
  metadata: {}
  data:
    evaluate_payload: false
    qos: 0
    topic: zigbee2mqtt/LIGHT_FRIENDLY_NAME/set
    payload: "{\"effect\": \"EFFECT_NAME\"}"

e.g.

- action: mqtt.publish
  metadata: {}
  data:
    evaluate_payload: false
    qos: 0
    topic: zigbee2mqtt/Living Room Office Desk/set
    payload: "{\"effect\": \"okay\"}"

Hope this is helpful to you.

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.

Best regards,
Flo