Door Open for X minuts

I have found many topics showing me the code but it does not seem to work? Any idea what I am doing wrong? I want to be notified if my front door is open for more than 5 minutes…
Here is my automation

  - alias: "Front Door Open"
    trigger:
      platform: state
      entity_id: sensor.FrontDoor
      state: 'open'
      for:
        minutes: 5
    action:
      service: notify.pushbullet
      data:
        title: "Front Door Open"
        message: "Front Door Open"

and my sensor…

- platform: mqtt
  name: "FrontDoor"
  state_topic: "smartthings/Front Door/contact"
  qos: 0
  payload_on: "open"
  payload_off: "closed"
  device_class: opening

I get Invalid Config error on HA when it starts. Please help!

1 Like

Please post your code in a code block to keep spacing and formatting (as shown in the blue box above your post)

What is the error message you get? Is the sensor working?

After restarting HA I get

Invalid Config
The following components and platforms could not be set up:
automation
Please check your config

If I remove the “Front Door Open” in automation the error goes away.
I have not tested to see if the automation works, I was waiting for a clean restart.

state: open

Should be

to: open

2 Likes

Wow, always so simple, that removed the error, I will test when I get home. Thanks!!

1 Like

Did that work?
I had issues with this ‘for’ configuration before so I’ using an alert - which also has the benefit that it reminds me repeatedly:

alert:
  garage_door_open_long:
    name: Garage Door is still open!
    entity_id: binary_sensor.garage_door_sensor
    state: 'off'   # Optional, 'on' is the default value
    repeat: 5
    can_acknowledge: true  # Optional, default is true
    skip_first: true  # Optional, false is the default
    notifiers:
      - mypushbullet

Yes, changing “state” to “to” worked, I opened the door and 5 min later got a notification. Now I am going to change it to turn off my Nest Thermostat when the door is open for 5 min…

2 Likes

state trigger is deprecated since version 0.45 or so.
You have to use TO in triggers (and probably alerts as well) instead of STATE

so basically when you have somewhere

trigger:
  platform: state
  entity_id: YOURSENSOR
  state: 'on'

you must now use

trigger:
  platform: state
  entity_id: YOURSENSOR
  to: 'on'

When you upgrade HA, try to always read the breaking changes part in the docs to avoid these stuff to happen :wink: