thh
(Thomas H.)
February 1, 2024, 9:34am
1
Hi there,
my automation is configured to be triggered by state changes from any to any state. Then a notification is sent to me.
Currently I receive a lot of notifications saying “Changed to off, from off”
In my opinion this should not happen. What could be the reason for that behaviour?
thanks
Thomas
tom_l
February 1, 2024, 10:32am
2
Please share you automation yaml when asking questions like this. And format it for the forum correctly .
I’m guessing you have something like this:
trigger:
- platform: state
entity_id: sensor.foo
This will trigger on all state and attribute changes.
If you only want to trigger on all state changes but not attribute changes supply a null to:
trigger:
- platform: state
entity_id: sensor.foo
to:
Another option that only triggers on state changes and ignores unknown states:
trigger:
- platform: state
entity_id: sensor.foo
not_to:
- unknown
- unavailable
1 Like
thh
(Thomas H.)
February 2, 2024, 6:35pm
3
The Automation is as follows:
alias: "Papa - Wohnungstür "
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.papa_wohnungstur
for:
hours: 0
minutes: 0
seconds: 1
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.papa_wohnungstur
state: "on"
sequence:
- service: notify.automation_papa_group
metadata: {}
data:
message: "Papa: Wohnungstür geöffnet"
- conditions:
- condition: state
entity_id: binary_sensor.papa_wohnungstur
state: "off"
sequence:
- service: notify.automation_papa_group
metadata: {}
data:
message: >-
Papa: Wohnungstür geschlossen / Changed to
{{trigger.to_state.state}}, from {{trigger.from_state.state}}
default:
- service: notify.automation_papa_group
metadata: {}
data:
message: >-
Papa Wohnungstür in undefiniertem Zustand: {{
states('binary_sensor.papa_wohnungstur') }} Changed to
{{trigger.to_state.state}}, from {{trigger.from_state.state}}
mode: single
tom_l
February 2, 2024, 8:27pm
4
trigger:
- platform: state
entity_id:
- binary_sensor.papa_wohnungstur
to: # null to only triggers on state not attribute changes as I wrote above.
for:
hours: 0
minutes: 0
seconds: 1
1 Like
thh
(Thomas H.)
February 2, 2024, 9:25pm
5
Thanks!
I was so fixated on your
so I did´t properly read the rest - shame on me!
Just to be curious: can I find out which attribute triggered the change? I am somewhat confused by the documentation, especially which variables and functions are available at each point. Sometimes things are on the trigger page, then on the automation trigger page and anoth time on the notification page… Surely there is a system, I am just unable to grasp that yet
tom_l
February 2, 2024, 11:05pm
6
1 Like