Synology Surveillance Station and PTZ preset/movement Home Mode

Tags: #<Tag:0x00007f326f395258>

Hello Guys,
I have an Reolink E1 Pro and I can’t use ONVIF component of home assistant for move the camera to the desidered preset so I used the Surveillance Station installed on Synology for achieve this.

So if you have a synology you can move all configured camera (PTZ compatible) to the desidered position…

Before to start you have to create some preset in Synology Surveillance Station on the camera:
I have created some preset: Home, Living, Kitchen, Bedroom and Rack

You have to follow this step carefully :slight_smile:

  1. First thing open browser and put this string changing the value with your value

https://your_IP:your_port/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account=your_username&passwd=your_password&session=SurveillanceStation&format=cookie

And will be a web page with this similar results

{“data”:{“sid”:“urOZvm591S5A6D9LPN00502”},“success”:true}

  1. issue the second command for display all information of your cameras in the browser

https://your_IP:your_port/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=List&version=2

in this page you have to find with CTRL +F “cameraid=” and you will find all the IDs of the cameras configured in the synology, in my case the ID are 4 and 5. so keep a note of these IDs.

  1. Issue this command in the browser for be sure that the camera id is working

Remember to change cameraid= with your ID :slight_smile:

https://your_IP:your_port/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=GetSnapshot&version=1&cameraId=4&timestamp=1571412595&preview=true

and you will see the snapshot of your camera, If you don’t see it repeat the steps from number 1.

  1. Now we have to acquire the preset names created before (remember to change the cameraid with your ID) :slight_smile:

https://your_IP:your_port/webapi/entry.cgi?api=SYNO.SurveillanceStation.PTZ&method=ListPreset&version=1&cameraId=4

In my case the output on the browser is like this:

{“data”:{“offset”:0,“presets”:[{“id”:2,“name”:“Home”,“type”:0},{“id”:8,“name”:“Living”,“type”:0},{“id”:9,“name”:“Kitchen”,“type”:0},{“id”:10,“name”:“Bedroom”,“type”:0},{“id”:11,“name”:“Rack”,“type”:0}],“total”:5},“success”:true}

  1. now you can change the position of your PTZ camera to the desired preset ID:

for example move the camera to the rack (remember to change cameraid and presetid to your value)

https://your_IP:your_port/webapi/entry.cgi?api=SYNO.SurveillanceStation.PTZ&method=GoPreset&version=1&cameraId=4&presetId=11

and you will see the camera move to your preset :-)… tha’s great… but if you open an incognito tab you will se it don’t work… why? it’s missing the sid!!

  1. add the sid at the end of the url and test it:

&_sid=aZWZZAKvChwhrsdasda903122

https://your_IP:your_port/webapi/entry.cgi?api=SYNO.SurveillanceStation.PTZ&method=GoPreset&version=1&cameraId=4&presetId=11&_sid=urOZvm591S5A6D9LPN00502

  1. add to configuration.yaml this parameters:
  ss_preset_home:
    url: !secret ss_preset_home
    method: get
    verify_ssl: false
  ss_preset_rack:
    url: !secret ss_preset_rack
    method: get
    verify_ssl: false

Add the url to the secret.yaml

ss_preset_home: 
ss_preset_rack:

and restart Home assistant

There is the API for setting Home mode ON and OFF too…

Enable Home Mode

https://your_IP:your_port/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=true&_sid=urOZvm591S5A6D9LPN00502

Disable Home Mode

https://your_IP:your_port/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=false&_sid=urOZvm591S5A6D9LPN00502

use it in your automation.yaml when you go out or come back to home:

Example:

####################################################
#               Nico Out Casetta                   #
####################################################

- id: zone-nico-out-casetta
  alias: Nico is going out - Notification
  initial_state: 'on'
  trigger:
     platform: zone
     entity_id: device_tracker.nico_nico
     zone: zone.casetta
     event: leave
  condition:
     condition: time
     after: '07:00:00'
     before: '23:59:00'         
  action:
   - service: notify.hassnico_bot
     data:
       message: "Nico is going out from Casetta at {{ states('sensor.date_time') }}"
   - service: script.alexatraffic2
   - service: rest_command.ss_home_off

At Home

####################################################
#                  Nico Casetta 2                  #
####################################################
- id: zone-nico-casetta
  alias: Nico at Home 2 - Notification
  initial_state: 'on'
  trigger:
     platform: state
     entity_id: device_tracker.nicogalaxys8
     from: 'not_home'
     to: 'home'
  action:
  - service: media_player.volume_set
    data:
      entity_id: media_player.nicolo_s_bose_home_speaker_500
      volume_level: 0.3
  - delay: 00:00:02
  - service: notify.alexa_media
    data:
      target: 
        - media_player.nicolo_s_bose_home_speaker_500
      data:
        type: tts
      message: >
       {{ [
       "Bentornato a casa Nico",       
       "Nico sei finalmente a casa",
       ] | random }}
  - service: rest_command.ss_home_on

This is how it look on lovelace
At the top left there are Preset for camera… at bottom left Lights and on Bottom right the command for move the camera

Capture

more to come… PTZ command :slight_smile:

3 Likes

Thank you. helped me connect hassio with synology very quickly. Everything very well explained for people who start !!

1 Like

@Ciquattro Could you advise, if such _sid is a long-time token? I successfully receive it and everything works well, but after some days it stops working until I receive new token.

it’s not a long-time token… I noticed that after a reboot you need to renewthe _sid… :frowning:… from API documentation seems they don’t have the long live token