Automation ZG-101ZL Single Click question

I have a ZG-101ZL button to control a Zigbee socket for a floor lamp.
I’ve set up a Hold event trigger automation to toggle the socket on/off for the lamp. That works no-problem.
But I’d rather it just trigger with a Single button click event. The problem is, the Event type never changes from Single, only the event state timestamp changes.

I can’t seem to figure out how to trigger off the timestamp change only on a event_type:single

Pointers?
Thanks!

Ok. Well, it was just staring me right in the face it was so easy.
Just trigger off the state change of the timestamp event with the event_type equal to single.
Here’s the code generated by the Automation GUI, for anyone interested:

alias: Living Room Floor Lamp Button Control
description: ""
triggers:
  - trigger: state
    entity_id:
      - event.living_room_floor_lamp_button_action
    to: null
  - trigger: state
    entity_id:
      - event.living_room_floor_lamp_button_action
    attribute: event_type
    from: single
    to: single
conditions: []
actions:
  - type: toggle
    device_id: b54947b423a0104d259f67a448ae225f
    entity_id: a5a085c8f7ad66fd1a38dc0ba85da93d
    domain: switch
mode: single

Cheers!

Ok, well that didn’t quiet work in all cases. If the button (ZG-101ZL) goes ‘unavailable’ or ‘unknown’ and then come back on-line, that triggers an Event and update the timestamp. That, in turn, triggers the automation and turns the light on (or off).

Sooo, seeing as I only have 2 entities to work with, how do I create an automation that ignores unknown and unavailable to “on-line” states so it doesn’t trigger and toggle the lamp?

Thank!

P.S. I really would prefer to do this via the UI and not code directly in Yaml.

You’ll have to switch to yaml mode, but this should work

alias: Living Room Floor Lamp Button Control
description: ""
triggers:
  - trigger: state
    entity_id:
      - event.living_room_floor_lamp_button_action
    not_to: 
      - unavailable 
      - unknown 
  - trigger: state
    entity_id:
      - event.living_room_floor_lamp_button_action
    attribute: event_type
    from: single
    to: single
conditions: []
actions:
  - type: toggle
    device_id: b54947b423a0104d259f67a448ae225f
    entity_id: a5a085c8f7ad66fd1a38dc0ba85da93d
    domain: switch
mode: single

Note I had to freehand the change on mobile so might have typos or indentation errors.

Also, your second trigger doesn’t do anything. The state will never change from single to single, since there’s no change involved.
You need to move the single check to the conditions section if you want it to work as intended.

1 Like

Thank you! I will give that a try.

The second trigger was to try to filter out holds, double-clicks, etc. But I see your point: a trigger only triggers on a state change.

1 Like