Aldopez
(Aldopez)
June 11, 2022, 3:59pm
1
I’m trying to make a movemente sensor from a motioneye webhook (start and end event). Im using motion_width data to do it. If I define a template sensor i can see the postive value when motion is detected and 0 when the end webhook is called. But when I convert the sensor to binary is always “not detected”
- trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: a00af3f7f4b09e2cdad71d230ea8af96
- platform: event
event_type: motioneye.motion_ended
event_data:
device_id: a00af3f7f4b09e2cdad71d230ea8af96
binary_sensor:
- name: Movimiento Living
state: "{{ trigger.event.data.motion_width | int }}"
device_class: motion
What i’m doing wrong?
Dujith
(Charles Evers)
June 11, 2022, 4:08pm
2
In the dev tools, what does {{ trigger.event.data.motion_width | int }}
produce?
Aldopez
(Aldopez)
June 11, 2022, 11:41pm
3
It’s possible to test a template based on event’s data?
For testing purposes I’ve defined this sensor
- trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: a00af3f7f4b09e2cdad71d230ea8af96
- platform: event
event_type: motioneye.motion_ended
event_data:
device_id: a00af3f7f4b09e2cdad71d230ea8af96
sensor:
- name: Movimiento Living (no motion)
state: "{{ trigger.event.data.motion_width | int }}
It show >zero or zero when movement is detected or not
Aldopez
(Aldopez)
June 12, 2022, 12:57am
4
Solved!
Just in case there is anyone interested. This is my correct code to generate a binary_sensor using the webhooks from motioneye for detect movement.
template:
# Template motion sensor camara Living
- trigger:
- platform: event
event_type: motioneye.motion_detected
event_data:
device_id: a00af3f7f4b09e2cdad71d230ea8af96
binary_sensor:
- name: Movimiento Living
state: "{{ trigger.event.data.motion_width | int > 0}}"
device_class: motion
You need to set the “ended webhook” manually in motioneye for this to woek. Just copy the start webhook text activate and paste below
Thx
Aldopez
(Aldopez)
June 12, 2022, 4:21am
5
I forgot to mark my last post as the Solution… thx @tom_l