Trigger a manual Synology Surveillance Station recording with an RF Door Sensor

I wanted to be able to manually trigger a recording on my Surveillance Station, you can use I/O devices such as the Advantech ADAM-6050. But using I/O devices uses up a device (Camera) licence. So I wanted an alternative option.

Luckily there is the “Action Rule” which allows you to trigger a recording using the API.

I am using a Sonoff RF Bridge flashed with Tasmota Firmware and a Kerui D026 RF Door / Window Switch in this example.

First Step is to create an Action Rule


Click on Add first.
You will want to give it a Name, select triggered and decide if you want the recording Interruptible or not.


Select “External device” under “Event Source” You can have up to 10 External Events.
Then click on “Get Command”


Copy and paste the block of code somewhere safe for now such as a text editor. You will need to change {account} and {password} to your username and password details.


Select which Camera you want to record, select “Start action rule recording” under “Action” and select how long you want to record for when triggered under “Duration”
On the next page select the trigger schedule. I left it at the default 24/7. But you could select during the night or when you are at work etc.


Next step is to log into your SonoffRF Bridge with Tasmota Firmware installed and go to the console page.
You want to look for the Data it gives for when the door / window is open.
In my case the Data ending EE is for the device open and E7 is for when it’s closed.
On this Kerui D026 there is also a third code ending EB stating it’s being tampered with (removed from the object it’s attached to) Note the full Data Code down for open ie 2xxxEE.

Now it’s time to add code into Home Assistant.
You will need to setup MQTT first to communicate to the RF Bridge running Tasmota Firmware.
Then add the following code bits you saved from earlier.

configuration.yaml

rest_command:
  gate_record:
    url: 'https://ipaddress:5001/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method="Trigger"&version=1&eventId=1&eventName="This is external event1"&account="username"&password="password"'

automations.yaml

- alias: RecordGateOpen
  trigger:
    platform: mqtt
    topic: tele/sonoffBridge/RESULT
  condition:
    condition: template
    value_template: '{{ trigger.payload_json.RfReceived.Data == "2XXXEE" }}'
  action:
    - service: rest_command.gate_record

Now hopefully when your Door / Window goes into open state it will trigger Surveillance Station to record on the Camera you selected. You can tell triggered recording in Surveillance Station as they have a pinky purple colour box to them instead of green.

4 Likes

Thank you for writing this up.

I’m about to buy a Synology NAS primarily for Surveillance Station and also to run my HA.

Do you think it’s possible to use the Surveillance Station camera motion alarm aa an input to HA for triggering lights etc - essentially the reverse of what you’ve done here?

You can do the reverse setup on the Synology where it triggers a url when there is camera motion for example.

You would have to use something like Long Lived Access Token or some websocket setup. But it’s not something I have tried so don’t know how to setup HA.

Some Cameras such as the HikVision range have a sensor setup in HA which I am about to try out later.
I am going to have a line crossing trigger on the camera turn on the garage light if its dark.

So, you think that will work with a local URL? I want to avoid using anything outside of my home network.

Yes it should be possible.
I just don’t know how to setup HA to listen / respond to a url

Like I say the other options it to look if your camera has sensor support already.

Do you have the cameras already or do you still need to buy them?

On the HikVision cameras you can setup things like line crossing detection and then the HA sensor for HikVision will change state if that event happens.

No, I don’t have the cameras yet but I’ll take your advice and look for ones with line crossing. That would be really handy for triggering lights.