Template binary_sensor problem

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?

In the dev tools, what does {{ trigger.event.data.motion_width | int }} produce?

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

descargar

imagen_2022-06-11_204125461

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

I forgot to mark my last post as the Solution… thx @tom_l