Send notification on door open

I want to setup an automation to send a notification to my phone when the front door is opened. I’m not sure what I’m missing. The senor is on my overview page and changes status when the door is opened but, I can’t seem to get the automation to work properly. I have executed it manually and the notification goes to my phone so, I know that part is working. Any assistance or advice is greatly appreciated. This is my first time posting; however, without this forum, I never would have gotten HA setup!

- id: '1607'
  alias: Front door open
  description: ''
  - platform: state
    entity_id: binary_sensor.front_door
    attribute: device_class
    to: open
  condition: []
  - service: notify.mobile_app_pixel
      message: Front door open
  mode: single

If your sensor is really a binary_sensor, the states is either on or off

Thank you for the reply. I tried ‘on’ to no avail. HA automatically read the sensor as binary and it appears to respond correctly on the overview page. I did try ‘sensor.front_door’ as the entity_id with various “to” commands but, that didn’t work either.

The trigger part is wrong, you’re matching on a state attribute rather than the actual state. It should be:

- platform: state
  entity_id: binary_sensor.front_door
  to: 'on'

The reason it’s working when you execute it manually is because that skips the triggers/conditions and only executes the actions (which you have correct).

You can find both the entity ID and state inside Developer Tools -> States.

Thank you! I tried ‘on’ previously and it did not work. However, I took out the attribute line, tried again, and it worked! I think device_class was not defined correctly in the above code so it just messed the automation up. The device_class is already assigned to the sensor so, it worked without it anyways.

Thanks again!

1 Like