How to prevent an automation from running when a door is open

I’m a noob and it’s been less than a week since I’ve moved from HE to HA. The transition has gone well but I’m stuck at 1 issue I’m having which is more of a reflection on me than it is on HA. I have an automation that turns off all the lights in the house. However I do not want to be able to execute the automation when a door is open. I have tried several variations but cannot get it to prevent the automation from running.

platform: device
device_id: fed4a3e5fbd0fc2926ddb5dc3ee3f632
domain: zwave_js
type: event.value_notification.central_scene
property: scene
property_key: '002'
endpoint: 0
command_class: 91
subtype: Endpoint 0 Scene 002
value: 2

condition: state
entity_id: binary_sensor.samjin_multi_490e0301_ias_zone
state: Closed

service: scene.turn_on
  entity_id: scene.goodnight
metadata: {}

Thanks for any help you can provide.

Suggest you try in the automation builder … your YAML indentations appear a little off.

The condition is the way to do it … likely main issue is that the state of the condiiton is wrong - check the state in the states tool (Developer Tolls → states) for the entitry you are checking to see what its states are. At the very least, likely lowercase - but could be on/off true/false … depends on the entity setup

Again - if you build a dummy automation in the automation editor, you can then see they YAML it produces to get correct syntax (assuming you are using YAML for your automations per they way you have formatted your dump.

Hope this helps - welcome aboard


Thanks for the direction guys it put me on the right path and I have resolved the issue. Just incase anyone is interested here’s what I ended up with.

type: is_not_open
condition: device
device_id: 7a6658ebbb0fdbbbcdc1e44ad254a379
entity_id: binary_sensor.samjin_multi_490e0301_ias_zone
domain: binary_sensor

Check your state

It should off not closed