How to code this automation trigger?

I have a Samsung Z-Wave sensor which has the following entities:


I want to write an automation which is triggered by the following:
a) Sensor contact changes to open OR
b) There is a change in x coordinate OR
c) There is a change in y coordinate OR
d) There is a change in z coordinate

How to code this trigger?

  - platform: state
      - sensor.gdo_sensor_x_coordinate
      - sensor.gdo_sensor_y_coordinate
      - sensor.gdo_sensor_z_coordinate
  - platform: state
    entity_id: binary_sensor.gdo_sensor_contact
    to: 'on'

Edit: Misread initially, this should be all you need.

1 Like

How does this check for a change in state of x or y or z coordinates? I am curious because I am still very new to HA and learning. Would appreciate some more insight.


The fact that the platform is state means it will trigger based on a change in state of the given entity_id, or in this case the list of sensors. Not specifying what state were are changing from or to means that the automation will be triggered on ANY state change. Triggers are always treated as an OR, meaning any of them becoming true will start the automation.

That totally makes sense. When listening to events I noticed that the x, y and z coordinates were just numbers and from_state and to_state changed rapidly as I moved the door. So, I got side-tracked into from_state, to_state and template triggers and whatnot. Didn’t realize that this would be as simple as on. I always assumed that on and off were for switches and lights only. Thanks for explaining so patiently…!!!