Synology Camera [SOLVED]

I have Synology NAS with surveillance station running and tried to add it to home assistant with the Synology platform., but can’t seem to get it to work. I keep getting the following error message…

Invalid config for [camera.synology]: required key not provided @ data['password']. Got None
required key not provided @ data['url']. Got None
required key not provided @ data['username']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/camera.synology/
Invalid config for [camera]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 146). Please check the docs at https://home-assistant.io/components/camera/
Invalid config for [camera]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 146). Please check the docs at https://home-assistant.io/components/camera/
Invalid config for [camera]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 146). Please check the docs at https://home-assistant.io/components/camera/
Invalid config for [camera]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 146). Please check the docs at https://home-assistant.io/components/camera/

This is what added to my config yaml…

#Synology NAS
camera:
 - platform: synology
 - url: https://xxxxxx
 - username: Home Assistant
 - password: xxxxxxx

Any sugestions?

you dont need the - for all the lines, just the - platform

Duh, and this is why I am not a computer programmer…lol. So, code is fine now, but no camera feeds in HA. Getting this error message on boot…

Mon Dec 03 2018 22:54:14 GMT-0500 (Eastern Standard Time)

Error when initializing SurveillanceStation
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/camera/synology.py", line 53, in async_setup_platform
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/synology/surveillance_station.py", line 12, in __init__
    self._api = Api(url, username, password, timeout, verify_ssl)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 59, in __init__
    self._initialize_api_info()
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 70, in _initialize_api_info
    payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 192, in _get_json_with_retry
    return self._get_json(url, payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 198, in _get_json
    response = self._get(url, payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 185, in _get
    verify=self._verify_ssl)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 524, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 631, in send
    adapter = self.get_adapter(url=request.url)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 722, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for '192.168.1.118:5101/webapi/query.cgi'

the line at the end looks like the url is invalid…

raise InvalidSchema("No connection adapters were found for '%s'" % url)

requests.exceptions.InvalidSchema: No connection adapters were found for 192.168.1.118:5101/webapi/query.cgi

So it cant connect. Either check the IP, or the port and make sure you have the correct credentials.

are you sure you are using https:// not http:/

Got the URL sorted out, tried a few different iterations because I am using SSL. Now left with just this…

Tue Dec 04 2018 07:59:29 GMT-0500 (Eastern Standard Time)

Error when initializing SurveillanceStation
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/camera/synology.py", line 53, in async_setup_platform
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/synology/surveillance_station.py", line 12, in __init__
    self._api = Api(url, username, password, timeout, verify_ssl)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 60, in __init__
    self._initialize_api_sid()
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 88, in _initialize_api_sid
    response = self._get_json_with_retry(api['url'], payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 192, in _get_json_with_retry
    return self._get_json(url, payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 207, in _get_json
    raise ValueError('Invalid or failed response', content)
ValueError: ('Invalid or failed response', {'error': {'code': 400}, 'success': False})

have you tried ssl_verify: false if using a local IP (not an expert on certs, but I imagine the cert is expecting a sub.domain.com)

Given you are using Synology NAS are you also using the reverse proxy (which is just a GUI on NGINX)?

Using internally I had to use IP addresses, but externally I had to set all my reverse proxy settings in the application portal, under control panel.

What happens when you put the URL you provide to HA into a browser? do you get surveillance station login?

Yeah, I put ssl to false and used the internal ip of the NAS. The same ip, brings me right to the login page using a browser. It’s unsecured though. I also tried my synology.me address, which has a valid cert and is secure. I tried that one with ssl to true and it still didn’t work. I also have a paid domain that I forward to the synology.me. I haven’t tried that one yet, but since it is just forwarding the address, I imagine I would get the same result.

1 Like

Looks like I am getting closer, went with one of my domain names that gets forwarded to the synology.me account. It sees it, but is refusing connection. Oddly, the NAS shows the Home Assistant user I created for HA is connected.

Log Details (ERROR)
Tue Dec 04 2018 18:09:32 GMT-0500 (Eastern Standard Time)

Error when initializing SurveillanceStation
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 301, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x705b5bb0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='guardian.coscia.network', port=443): Max retries exceeded with url: /webapi/query.cgi?api=SYNO.API.Info&method=Query&version=1&query=SYNO.API.Auth%2CSYNO.SurveillanceStation.Camera%2CSYNO.SurveillanceStation.Camera.Event%2CSYNO.SurveillanceStation.VideoStream (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x705b5bb0>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/camera/synology.py", line 53, in async_setup_platform
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/synology/surveillance_station.py", line 12, in __init__
    self._api = Api(url, username, password, timeout, verify_ssl)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 59, in __init__
    self._initialize_api_info()
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 70, in _initialize_api_info
    payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 192, in _get_json_with_retry
    return self._get_json(url, payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 198, in _get_json
    response = self._get(url, payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 185, in _get
    verify=self._verify_ssl)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='guardian.coscia.network', port=443): Max retries exceeded with url: /webapi/query.cgi?api=SYNO.API.Info&method=Query&version=1&query=SYNO.API.Auth%2CSYNO.SurveillanceStation.Camera%2CSYNO.SurveillanceStation.Camera.Event%2CSYNO.SurveillanceStation.VideoStream (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x705b5bb0>: Failed to establish a new connection: [Errno 111] Connection refused',))

Still haven’t had much luck. Do you think it’s because I have HTTP forwarded to HTTPS automatically? I have ssl set to true.

Turned off the HTTPS redirect and still can’t get it to work. This is the error message I am currently getting for SS…

Log Details (ERROR)
Sat Dec 15 2018 12:33:05 GMT-0500 (Eastern Standard Time)

Error when initializing SurveillanceStation
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/camera/synology.py", line 53, in async_setup_platform
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/synology/surveillance_station.py", line 12, in __init__
    self._api = Api(url, username, password, timeout, verify_ssl)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 60, in __init__
    self._initialize_api_sid()
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 88, in _initialize_api_sid
    response = self._get_json_with_retry(api['url'], payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 192, in _get_json_with_retry
    return self._get_json(url, payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 207, in _get_json
    raise ValueError('Invalid or failed response', content)
ValueError: ('Invalid or failed response', {'error': {'code': 400}, 'success': False})

Do you have the port number at the end of the IP address and have you tried creating a new user account in your Synology without the space?
I have http to redirect to https.
Also have you given your username permission to access Surveillance Station?
This is how my setup is, but with different user name a password.

camera:
  - platform: synology
    url: https://192.168.1.2:5001
    username: homeassistant
    password: password
    timeout: 15
    verify_ssl: False

Thanks for the reply! Taking the single space out of the user name did the trick! Thank you so much for the help. Now to see if it will still work with https redirect on. :slight_smile:

Glad you got it sorted.

Are you hosting your Home Assistant on your Syno as well?

A couple of weeks ago I did a basic automation to trigger recordings on the Surveillance Station based on a sensor trigger. Might give you some ideas on how to Integrate / Automate Surveillance Station a bit more with Home Assistant.

Thanks, don’t know if I would have solved the issue without your help. Although I did notice the feed doesn’t seem to be live video, it is a static image that is updated every 10 seconds. Is that normal?

I actually have two Synos, an older DS214play that I use for file sharing and a new DS718+ that I use exclusively for SS. I’ll probably replace the DS214play with a DS918+ soon, I host cloud storage for my entire family and need the additional disk bays for storage.

I primarily use SmartThings for my home automation, but have Home Assistant running in parallel (minus all z-wave devices) on a raspberry pi. I think it’s inevitable before Samsung kills the openness of SmartThings, so trying to prepare myself for the jump. HA has a higher learning curve, so taking it slow and steady.

Thanks for the link! Right now I am recording 24/7, but will probably have to cut back as I add more cameras. Again, thanks for all the help!

The main interface is an almost static image like you say, updates every 10 seconds or so.

Click on the camera image and it updates quicker.

I would move away from 24/7 recording and use motion detection. It’s not 100% but safes on having to view hundreds of hours of footage to find an event.

That’s why I like to use external sensors like a Door / Window sensor or a PIR sensor. You can trigger a recording you might normally miss. But if the sensor is set right it wont be triggered from false readings.

Has anyone had any issues with Synology CPU usage recently? My Hassio is pulling images every 10 seconds or so, and it’s pushing my 215j to the limit, it’s 100% CPU usage at all times. It’s so bad I can’t even access the Synology web interface with shutting Hassio down. It’s only started happening recently, and it’s made my NAS nearly useless.

what SS are you running? 8.2.3 ? there are some issues, at this moment they are developing a new .py file

you can join the testing here :

Yeah, the latest SS. Thanks for the link.

are you using 8.2.3 already?
because also, in older SS versions there were indeed CPU issues, nothing related to HA

Yeah 8.2.3 5828

Still sitting at 99% doing nothing. When I turn my Hassio off, CPU use on the synology drops down to 0-30%, so it’s the Hassio pulling those images.