Webhook to binary sensor

Hey folks,

I am trying to convert a webhook into a binary sensor and struggling a bit. I have done some searching and tried to adapt other examples I have seen but failing with it.

Here is the template I have built:

- trigger:
  - platform: webhook
    webhook_id: long_uuid
    binary_sensor:
    - name: "webhook_status"
      state: "{{ state_attr('states.trigger.json.status', 'status') == 'up' }}"
      device_class: opening

The webhook sends a payload of {“status”: “$STATUS”} which is either up or down

I want to convert up to True or On and down to False or OFF

Any ideas where I am going wrong?

Cheers

J

1 Like
- trigger:
    - platform: webhook
      webhook_id: long_uuid
  binary_sensor:
    - name: "webhook_status"
      state: "{{ trigger.json.status == 'up' }}"
      device_class: opening

References:

@123 Thank you!

It works perfectly

1 Like

Hi Jon, How did you find the payload of your webhook? I have a motion class webhook being sent from MotionEye but I have no idea how to get the contents of the webhook for templating / debugging.