I have just tried my first automation. I want to send an alert to my mobile when the front door bell rings. The door bell is connected to the input of a Shelly switch. The first version works well, but as expected, it triggers when the switch state changes from off to on, and then again from on to off. The Yaml is below, but I actually edited the automation in the configuration editor.
- id: '1636630015968'
alias: Front Door Bell
description: Alert on door bell
trigger:
- platform: state
entity_id: switch.front_door_bell_switch_0
condition: []
action:
- service: notify.mobile_app_s20fe
data:
title: Front door bell
message: '{{states.switch.front_door_bell_switch_0.state}} at {{ now().strftime(''%H:%M:%S'')}}'
mode: single
So I then added the ‘on’ state to the ‘to’ field of the trigger, which resulted in this
- id: '1636630015968'
alias: Front Door Bell
description: Alert on door bell
trigger:
- platform: state
entity_id: switch.front_door_bell_switch_0
to: 'On'
condition: []
action:
- service: notify.mobile_app_s20fe
data:
title: Front door bell
message: '{{states.switch.front_door_bell_switch_0.state}} at {{ now().strftime(''%H:%M:%S'')}}'
mode: single
but now the automation does not trigger at all I have tried various combinations of typing the on state ie On “On”, ‘On’
In the first version the notification correctly displays the switch state as On then Off
Any suggestions how to correctly detect the On state?
Thanks