Hello Guys
I looking for a way to toggle on and off the motion sensors by NFC tag, But unfortunatley the toggle automation with NFC doesn’t work and sometime it is only disable the automation and never toggle it as it plans!
my YAML code is like this:
alias: Tag Unlock key
description: ""
trigger:
- platform: tag
tag_id: 5a75176a-a649-44e1-a7cb-2ce702152607
condition: []
action:
- service: automation.turn_off
data:
stop_actions: true
target:
entity_id:
- automation.motion_sensor_backdoor
- automation.motion_sensor_2_back_door
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
- service: automation.turn_on
data: {}
target:
entity_id:
- automation.motion_sensor_backdoor
- automation.motion_sensor_2_back_door
mode: restart
Arh
May 2, 2023, 3:53pm
2
Sure there will be a better way, but you could use the choose action with condition of whether the automation is on or off.
Can you please explain more?
Arh
May 3, 2023, 10:38am
4
Trigger exactly as you are
But in the action pick the choose option. Use the condition pick state, pick your automation, and for state select on.
then pick action, call service turn automation off, pick your automation.
then for default action pick call service and turn on automation, pick your automation.
Should work but not tried anything like that, so may take some fiddling about.
1 Like
I just tried that and doesn’t work.the state of automation not toggle off and nothing happens
Arh
May 4, 2023, 1:39pm
6
show us the yaml, then someone will be able to help.
sure.here is the YAML
alias: Tag Unlock key
description: ""
trigger:
- platform: tag
tag_id: 5a75176a-a649-44e1-a7cb-2ce702152607
condition: []
action:
- condition: state
entity_id: automation.motion_sensor_backdoor
state: "off"
for:
hours: 0
minutes: 15
seconds: 0
- condition: state
entity_id: automation.motion_sensor_2_back_door
state: "off"
for:
hours: 0
minutes: 15
seconds: 0
- condition: state
entity_id: automation.motion_sensor_backdoor
state: "on"
for:
hours: 0
minutes: 0
seconds: 0
- condition: state
entity_id: automation.motion_sensor_2_back_door
state: "on"
for:
hours: 0
minutes: 0
seconds: 0
mode: single
Arh
May 5, 2023, 7:57pm
8
There is no choose action in that yaml. Not sure what you did pick as action.
I set the actions as state, as you said.
Arh
May 7, 2023, 6:34am
10
except for the bit where i said
But in the action pick the choose option
thank you so much.
I changed it to what you said.
is this what you are looking for?
alias: Tag Unlock key
description: ""
trigger:
- platform: tag
tag_id: 5a75176a-a649-44e1-a7cb-2ce702152607
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: automation.motion_sensor_backdoor
state: "on"
sequence:
- service: automation.turn_off
data:
stop_actions: true
target:
entity_id:
- automation.motion_sensor_backdoor
- automation.motion_sensor_2_back_door
default:
- service: automation.turn_on
data: {}
target:
entity_id:
- automation.motion_sensor_backdoor
- automation.motion_sensor_2_back_door
mode: single