Automation with notification, but only if state changed

Hey,

So I have an automation that runs whenever one out of the people from my household enters the home.
It will then run a script that disables the alarm.
Now I’ve also added a notification to let met know when that happens.

However it looks like the event is triggered multiple times, even without the state of the alarm being set to off.

So how could I configure it to only notify me if the alarm state was set to on, before switching it off.
The alarm is switch.alarm and has state on and off.

alias: Het huis betreden
description: ''
trigger:
  - platform: zone
    entity_id: person.dennis_vermaut
    zone: zone.home
    event: enter
  - platform: zone
    entity_id: person.eve_artsy
    zone: zone.home
    event: enter
  - platform: zone
    entity_id: person.my_child
    zone: zone.home
    event: enter
condition: []
action:
  - scene: scene.present_in_house
  - service: notify.notify
    data:
      message: The alarm is now deactivated.
      title: The alarm is now deactivated.
mode: queued
max: 10

Add a condition to the automation so it only continues / triggers if the alarm state = on

That was indeed just plain dumb of me…
Instead of checking the previous state for the notification, just run the automation only if it’s already in the right state…

Thanks!!

Sometimes you can’t see the obvious and the longer you look the less obvious it is, that’s why home assistant community is so helpful, glad you got it sorted :+1:t2:

1 Like