rinners
(rinners)
August 12, 2023, 7:07pm
1
I’ve set up a motion detection trigger to change a binary sensor state in my templates.yaml as follows:
trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
binary_sensor:
- name: "Camera4 Movement"
state: "true"
device_class: motion
auto_off: 10
And this works just fine.
However
I want to do multiple different sensors and I’ve tried the following:
trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
binary_sensor:
- name: "Camera4 Movement"
state: "true"
device_class: motion
auto_off: 10
trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
binary_sensor:
- name: "Camera5 Movement"
state: "true"
device_class: motion
auto_off: 10
trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
binary_sensor:
- name: "Camera6 Movement"
state: "true"
device_class: motion
auto_off: 10
With this code it only generates a single sensor namely “Camera6 Movement” which only Camera6 triggers. I’ve tried getting them all to trigger one binary sensor, but no luck either, only the last trigger works.
I would like to have a binary sensor for each trigger.
You need to properly format your list using -
to indicate each item, otherwise each subsequent entry overwrites the previous… YAML for non-Programmers
rinners
(rinners)
August 12, 2023, 7:34pm
3
Thanks and what would the formatting need to look like in this case?
rinners
(rinners)
August 14, 2023, 9:18am
4
I haven’t figured out how to do multiple triggers to different binary sensors yet, but I did fix some other sensors that I had broken
Previously I had
trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
binary_sensor:
- name: "Camera4 Movement"
state: "true"
device_class: motion
auto_off: 10
sensor:
- name:
sensors:
name_of_sensor_only
sensor data:
Where it should have been
- trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
binary_sensor:
- name: "Camera4 Movement"
state: "true"
device_class: motion
auto_off: 10
- sensor:
- name:
- sensors:
name_of_sensor_only
sensor data:
mekaneck
(Rick Auch)
August 14, 2023, 10:09am
5
You set up a trigger and then you place as many sensors as you want operated off that trigger below it. Then you list a new trigger and repeat. E.g.:
- trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: 'xxxx4'
binary_sensor:
- name: "Camera4 Movement"
state: "true"
device_class: motion
auto_off: 10
- trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: 'xxxx5'
binary_sensor:
- name: "Camera5 Movement"
state: "true"
device_class: motion
auto_off: 10
…
rinners
(rinners)
August 17, 2023, 6:19pm
6
Thanks seems I was missing the list -'s needed for the trigger: sensor: & sensors: parts.
I guess it was only seeing it as a single entry rather than a list?
mekaneck
(Rick Auch)
August 17, 2023, 11:31pm
7
The sensors:
part is old legacy formatting that should be converted over to the new format. But yes HA may have been only looking at the first item since you omitted the ‘-‘. But I’m not certain how HA interprets code that doesn’t match the recommended formatting.