Why does this automation not trigger?

My automation does not work, it doesn’t seem to trigger at all. It shows no traces. I don’t know where to start to debug this problem. This is my first automation and blueprint, so I feel like I’m just missing something obvious.

I created this blueprint based on another blueprint I found online. It simplified it to remove error causes.

I created an automation based on the blueprint passing my window sensor (silvercrest window sensor) and my own phone (home assistant app installed and has rights). The sensor in home assistant correctly switches between open and closed, but the automation does not seem to trigger at all. No trace, no notification nothing. What am I missing?

blueprint:
  name: 'Notification to Close a Window (custom sensor)'
  description: Notification to close windows
  domain: automation
  input: 
    contact_sensor: 
      name: Contact Sensor
      description: 'The window or door sensor that triggers the automation.'
      selector: 
        entity:
          domain: binary_sensor
    device_identifier:
      name: Device to notify
      description: 'The device to receive the notification'
      selector: 
        device:
          integration: mobile_app

trigger:
- platform: state
  entity_id: !input contact_sensor
  from: 'closed'
  to: 'open'
  for:
    hours: 0
    minutes: 1
    seconds: 0

condition:
- condition: state
  entity_id: !input contact_sensor
  state: 'open'

action:
- device_id: !input device_identifier
  domain: mobile_app
  type: notify
  message: 'Time to close {{trigger.to_state.attributes.friendly_name}}.'
  title: 'Close {{trigger.to_state.attributes.friendly_name}}!'

If you go to the development tab in HA and lookup the current state of that window sensor. What does it say? Could it say “off” instead of “closed”? Because if it does, it will never start the automation.

Your blueprint’s selector is for a binary_sensor. A binary_sensor’s states are on or off. Your blueprint’s State Trigger is looking for a state-change from closed to open. That will never happen because those are values shown exclusively in the Lovelace UI (for example, for a binary_sensor with a “door” or “window” device_class).

Change it to:

  from: 'off'
  to: 'on'

For the same reason, change the State Condition’s value from open to on.

BTW, that State Condition is superfluous. The automation has one State Trigger that triggers only when the binary_sensor’s state changes to on so there’s no need for a State Condition to confirm the state is on.

Thank you so much, it does indead say “off”. Good tip with the development tab.

About the condition, I only copied the blueprint but I believe the condition makes sure the window is still open after the timer has completed. Does that make sense? The script source is [here].(Notifications to close an open door or window after a set number of minutes)

It does, but it’s still wrong and 123 is correct. Change it to on/off

As I already mentioned in the previous answer using the approach from frits1980 did the trick. the second comment was just about 123 questioning the condition. I just wanted to mention it because I’m not sure either.

Thanks for all the answers :slight_smile:

Tell me how it could be anything other than open (on) when the trigger fires. You’ve configured the State Trigger to fire only if the state is on. Are you concerned that a microsecond after the trigger fires, the state changes to off?

The trigger has a 1 minute timer on it, so I understand that in that time the state could change right?

You don’t appear to understand how a State Trigger employs its for option. I recommend you review the documentation: Holding a State

The following State Trigger:

- platform: state
  entity_id: binary_sensor.door
  from: 'off'
  to: 'on'
  for:
    hours: 0
    minutes: 1
    seconds: 0

will trigger only when the door opens and remains open for at least 1 minute in order for the trigger to fire. If the door is closed at any time before 1 minute, the State Trigger resets its internal 1-minute timer. The state must remain on for 1 consecutive minute in order for the trigger to fire. When it does fire, the state is definitely on.