Automation triggered on state change instead of button press

hi folks, I’ve setup a rather straightforward automation but has just now behaved unexpectedly,

I have two devices, a Nuki smartlock with a button entity that opens the door and an Ezviz alarm that enables/disables notifications for sensors

in the automations UI i created the following, where WHEN the button for opening the door is pressed THEN it should disabled the alarms,

to my surprise, later today I found that the alarm got deactivated without me doing so nor opening the door, but it appears this happened because the nuki device at some point was not available:

but again the trigger I set up should be very clear, a button press is a button press, not a wild card on any device event,

why would this result in the trigger being activated?
feels like a bug, at least on the UI during setup

this is the yaml related to the trigger

Another reason not to use Device triggers…

You can switch to a State trigger which allows you to exclude values like “unavailable” and “unknown”…

trigger:
  - platform: state
    entity_id: button.EXAMPLE
    not_to:
      - unavailable
      - unknown
    not_from:
      - unavailable
      - unknown

… or you can use an Event trigger for the button.press service call.

  - platform: event
    event_type: call_service
    event_data:
      domain: button
      service: press
      service_data:
        entity_id: button.EXAMPLE
1 Like

more complex than expected :smiling_face_with_tear:
this also calls in question the claim on it being the first suggested option, or the claim that its the best way to start, as I started with that and failed immediatey :sweat_smile:

1 Like

Believe me, many of us have advocated for those things to be changed… :man_shrugging:

3 Likes


Should read: When something happens to a device, this completely breaks. Great way to get lost. :wink:

I was thinking something like:

or

2 Likes