Hey there, I wasn’t able to solve it directly in Home Assistant, but I found probably a better solution. Synology SS has an add on called Cluster Managment and I was able to create a cluster between the two DiskStations where the cameras are now combined on one UI of “the main DSM” thus all cameras show up in Home Assistant. As a plus I can manage everything through one surveillance station UI too.
Thank you!
I have managed to set it up that way and it is working great.
Sorry for diggind this topic but it’s driving me crazy.
@runevad I was able to get the token but now I have a problem calling this via “Service”
- service: rest_command.ss_disable_home
and - service: rest_command.ss_enable_home
The error is because I have ssl enable and the certificated is based on the NAS so:
aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host 192.168.1.5:5001 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)]
The rest command doesn’t have the parameter: veryfy ssl so i can’t set it to false.
How can i get pass this stage?
@kiucheng did you get that “auto cookie obtainer” to work?
Sorry for the late response but I can´t help you I’m afraid. I don’t run my setup using SSL locally (I’m only using SSL for non local connections) so for me this wasn’t an issue.
Looks like py-synology now supports home mode, which means this could be turned into a platform supported switch like it does for zoneminder.
Hmm I have no idea how to make that into a component but it sure would be a nice thing to have =)
Having all cameras recording based on just movement, and not knowing the mode of the rest of the house based on presence isn’t the nicest solution.
Hi to all, i’, getting “error”:{“code”:119},“success”:false, but if i put the entire URL with _SID i’, able to switch home mode.
ex: http://192.168.3.3:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=true get the error code 119
Does the link works all the time? My experience is the ‘sid’ changes from time to time. It’s not very practical to track the change manually and change it in HASS configuration. It would be good if there is a way to do this automatically by getting a sid before calling Home Switch and then splice it back into the url request
Does the service turn_off and turn_on works for synology camera? I call the service turn_off for cam.cam1 but my camera is still recording.
Still running HA on a Raspberry PI 3… I actually plan on moving it over to my Synology once HASOS works in a Virtualization Station VM Properly with USB support for Z-wave.
However for now my main issue is that this that I am now at 4 cameras and all of my cameras are 1080p or 1440p, it seems to be killing the HA PI trying to process these.
Any chance we can leverage the stream settings (High/Balanced/Low) in Surveillance station, or some built in thumb feature to send less traffic to the pi accept when in live view mode after clicking to expand a feed?
Edit:
After doing some more testing with the profiles it actually appears this component is bound to the Mobile Live View? As after altering my settings I noticed that HA had dropped in quality… While this is sort of good it does prevent getting a high quality view if you expand the image.
Hi.
I’m having trouble with the commands from time to time, it seems to work but the log shows the following errors:
Hassio version 77.3
It does the same thing with “status” but i have not seen it with “away”
The synology_home_mode.py is the following:
#!/usr/bin/python3
import sys
import requests
import json
PROTOCOL = "http" #Must be HTTP and not HTTPS
IP_ADDRESS = "IP" #Your Synology NAS ip address
PORT = "5000" #The port used by Synology DiskStation Manager
API_PATH = "/webapi/"
BASE_URL = PROTOCOL + "://" + IP_ADDRESS + ":" + PORT + API_PATH
API_AUTH_FILE = "auth.cgi"
API_CAMERA_FILE = "entry.cgi"
HOME_MODE = sys.argv[1]
AUTH_PAYLOAD = {'api': 'SYNO.API.Auth', 'version': '2', 'session': 'SurveillanceStation'}
LOGIN_PAYLOAD = {'method': 'Login', 'account': 'USERNAME', 'passwd': 'PASSWORD', 'format': 'cookie'}
LOGIN_PAYLOAD.update(AUTH_PAYLOAD)
LOGOUT_PAYLOAD = {'method': 'Logout'}
LOGOUT_PAYLOAD.update(AUTH_PAYLOAD)
if HOME_MODE == "status":
ACTION_PAYLOAD = {'api': 'SYNO.SurveillanceStation.HomeMode', 'version': '1', 'method': 'GetInfo'}
if HOME_MODE == "home":
ACTION_PAYLOAD = {'api': 'SYNO.SurveillanceStation.HomeMode', 'version': '1', 'method': 'Switch', 'on': 'true'}
if HOME_MODE == "away":
ACTION_PAYLOAD = {'api': 'SYNO.SurveillanceStation.HomeMode', 'version': '1', 'method': 'Switch', 'on': 'false'}
session = requests.session()
login = session.get(BASE_URL + API_AUTH_FILE, params=LOGIN_PAYLOAD, timeout=5)
action = session.get(BASE_URL + API_CAMERA_FILE, params=ACTION_PAYLOAD, timeout=5)
logout = session.get(BASE_URL + API_AUTH_FILE, params=LOGOUT_PAYLOAD, timeout=5)
session.close() #Closes session
if HOME_MODE == "status":
print(action.text)
My command_line switch is this:
- platform: command_line
switches:
synology_home_mode:
command_on: 'python3 custom_components/synology_home_mode.py home'
command_off: 'python3 custom_components/synology_home_mode.py away'
command_state: 'python3 custom_components/synology_home_mode.py status'
value_template: >
{% if value_json is defined %}
{{ value_json.data.on}}
{% else %}
{{ states.switch.synology_home_mode.state == 'on' }}
{% endif %}
friendly_name: SS Home Mode
In the following 3 lines
login = session.get(BASE_URL + API_AUTH_FILE, params=LOGIN_PAYLOAD, timeout=5)
action = session.get(BASE_URL + API_CAMERA_FILE, params=ACTION_PAYLOAD, timeout=5)
logout = session.get(BASE_URL + API_AUTH_FILE, params=LOGOUT_PAYLOAD, timeout=5)
try changing timeout=5
to timeout=10
On my DS918+, a unit which is more than powerful enough, I’ve been seeing slow response times from the API. That results in my Home Assistant log file being filled with errors like yours. Making the change above has definitely improved things, but it’s not the ideal solution. I’m still hoping someone will put time and effort into being able to control “Home Mode” from within Home Assistant out of the box.
Cheers, will try it later with a restart! Thanks!
A restart shouldn’t be necessary. The command_line
switch calls the external script everytime it’s needed so it always uses the current version.
I know but I need to do some other changes as well…
Hi, I can confirm your shell script is working well.
Trying right now to integrate it into an automation script.
Thanks!
I am having this same problem, found a solution?
@fanaticDavid & @JuRy
i am using your script, and have a dump question about the state switch
i am using this, and the states changes from my home mode switch
command_state: 'python3 /config/homemode.py status'
but if i run that command in putty, the getinfo indeed gives a lot of output data
but how the hell do you tell the switch state to be on of off? where is that link to true or false?
i see lots of info when i do that command, the only thing i dont see is that the home mode is actually on or off though, so just want to know how it works
https://www.dropbox.com/s/6ptp31x0tb4vdy8/homemode.JPG?dl=0
oh, and btw, for turning on/off home mode, i do it with actions,
on your SS you can create 2 actions, that can you execute with a command line, this is also working for me
so i have my switch :
- platform: command_line
switches:
home_mode:
friendly_name: Home Mode
command_on: 'curl -k "https://192.168.0.15:6003/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method="Trigger"&version=1&eventId=1&account=USERNAME&password=PASSWORD"'
command_off: 'curl -k "https://192.168.0.15:6003/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method="Trigger"&version=1&eventId=2&account=USERNAME&password=PASSWORD"'
command_state: 'python3 /config/homemode.py status'
value_template: >
{% if value_json is defined %}
{{ value_json.data.on}}
{% else %}
{{ states.switch.synology_home_mode.state == 'on' }}
{% endif %}
ok, found it
its the on json
value_json.data.on
there is actually a on = true or false between that huge text output