Send Synology Surveillance motion events to HA switch

Are you sending a POST request to a HA service? Not sure what the ‘events’ is you’re sending to. Try sending an API request to a service like I have /api/services/script/xxxx

Not sure what I did wrong but I was able to get it working by posting to the events API.

Thanks.

1 Like

Interested to know if this method is still working for you or if you now use an alternative?

Still working for me by firing a script using the following:
http://ha_ip_address:8123/api/services/script/trigger_ss_entrance_boolean

1 Like

This has now broken in 0.83.x. I’m assuming I’ll now need to use a webhooks link to my script. Anyone help with how to do that?

Wow. It is actually super simple now. Just create an automation that defines a webhook ID thus:

automation:
  - alias: 'Webhook endpoint to entry motion' ## http://hassio_ip:8123/api/webhook/motion_entrance ##
    hide_entity: true
    trigger:
      - platform: webhook
        webhook_id: motion_entrance
    action:
      - service: script.turn_on
        entity_id: script.trigger_ss_entrance_boolean
      - service: notify.hass_synochat
        data:
          message: "Entry motion webhook fired"

Mine is then calling this script which in turn fires an input boolean for 5s. I also have a notifier in my automation purely for testing purposes.

script:
  trigger_ss_entrance_boolean:
    alias: Trigger input boolean for motion from API
    sequence:
      - service: input_boolean.turn_on
        entity_id: input_boolean.motion_entrance
      - delay: 00:00:05
      - service: input_boolean.turn_off
        entity_id: input_boolean.motion_entrance
1 Like

Buggar. Seems all is not well in Synology. Although I can fire that webhook event using Postman or the Android HTTP app using a POST request, it does not work as a SS action rule. Back to the drawing board. Looks like I’m going to have to break out Wireshark again.

1 Like

This is as far as I got, Postman works great for both the webhook and the event trigger. Unfourtuently SS doesn’t and I struggled to find any further information on what SS does with the action URL. I’ll keep my fingers crossed you can sniff something with Wireshark.

I’ve had the same issue with webhooks not working from SS. I came to find out that SS only sends a GET request and does not set the content-type in header appropriately (HA expect application/json). As such, I created a Node-red flow to proxy the request to HA in the proper format.

So route the information takes is:
SS via the motion action sends HTTP GET request towards node-red listening on url. I used /synology_flows/:webhook, eg http://node.red.host/synology_flows/WEBHOOKID-devicename

Node red maps the provided webhook parameter towards the new POST request towards HASS and sets the content-type in header and also provides an empty (but defined) payload, eg, “{}”

This gets the motion events from synology into HA triggers, where you can do whatever you would want to set input_boolean, etc to act as a switch. I also have all my webhook IDs in this case start with a randomly generated string but also end with a “-devicename” so it can be referenced in automations.

- id: security_motion_events
  alias: Surveillance Motion event
  trigger:
    - platform: webhook
      webhook_id: !secret ss_camera_front_door_motion
    - platform: webhook
      webhook_id: !secret ss_camera_back_door_motion
    - platform: webhook
      webhook_id: !secret ss_camera_driveway_motion
    - platform: webhook
      webhook_id: !secret ss_camera_house_front_motion

  action:
  - service: notify.hass_notify_group
  data_template: >
    message: "Device {{ trigger.webhook_id.split('-')[1] }} just registered motion"

Amazing! Don’t suppose you’d mind sharing your Node-Red flow? What kind of latency do you get from this?

It’s pretty much instant as far as I can tell. Obviously limited by how quickly your camera signals the event and how loaded your system is, etc but it comes through very fast in my testing.

Here’s my node flow: click

1 Like

Thanks! You’ve just saved me heaps of headaches!

would you mind to explain in more details what a node.red is? Is this a service I need to install on the Synology?
How does it need to be configured?
This solution currently is not within my skills.
thx in advance

1 Like

Hi All! +1 for this - not sure what a node.red is…can you please expand on this?

Thanks a lot :slight_smile:

I don’t use it, but Home Assistant Community Add-on: Node-RED all the details are here.

Pleased to advise that the latest update of Surveillance Station (8.2.3-5828) fixes the Action Rules ability to send events to a webhoook URL in HA!! :slight_smile: How to do that is here Send Synology Surveillance motion events to HA switch

2 Likes

Is this still working for you? It’s recently broken for me.

I’ve done my best to document my findings here.

guys interesting thread, but i am also unable to fire a webhook from SS
as some screenshots above, where you create the action, i dont have “external device” i can choose only webhook
so i enter my nabucasa url there
but tried with post/get , nothing works, always test failed
if i test from SSH and the CURL - X POST https://xxx , then it works…

any idea?

Webhook is the correct action. ‘External Device’ is if you want to receive a request from HA to do something on your SS. I use this for PTZ control.

For Webhooks, you need to create a receiving automation inside HA though otherwise the request goes nowhere. Below is my SS action and part of the HA automation that receives the request. Use the LAN IP of your HA instance if both devices are on the same network.

  - alias: 'Webhook endpoint to entry motion' ## http://internal_ip-address-of-HA:8123/api/webhook/motion_entrance ##
    hide_entity: true
    trigger:
      - platform: webhook
        webhook_id: motion_entrance ## this is the only place you create the webhook ID ##
    action:
      - service: camera.snapshot
        data:
            entity_id: camera.proxy_entry
            filename: '/config/www/images/entry_cropped.jpg'
      - service: script.turn_on
        entity_id: script.trigger_ss_entrance_boolean

You can use the SS ‘Test Send’ button to see if it’s working.

Strange , I have the exact same thing… It also created a webhook url for nabucasa … That one is working when I do it with curl, but not with ss…

You are using the internal IP, that’s my goal also, and not the nabucasa one…

Strange that it works for you without authentication in that ss screenshot??? Or how did you configure that local ip addresses don’t need authentication?