Upgrade to 0.55.0 Synology camera not working anymore

As title says and this is in the log:

2017-10-08 18:47:55 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform synology
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 141, in coro
    res = func(*args, **kw)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/camera/synology.py", line 54, in async_setup_platform
    timeout=timeout
  File "/srv/homeassistant/lib/python3.4/site-packages/synology/surveillance_station.py", line 9, in __init__
    self._api = Api(url, username, password, timeout, verify_ssl)
  File "/srv/homeassistant/lib/python3.4/site-packages/synology/api.py", line 56, in __init__
    self._initialize_api_info()
  File "/srv/homeassistant/lib/python3.4/site-packages/synology/api.py", line 66, in _initialize_api_info
    response = self._get_json(self._base_url + 'query.cgi', payload)
  File "/srv/homeassistant/lib/python3.4/site-packages/synology/api.py", line 189, in _get_json
    content = json.loads(response.content)
  File "/usr/lib/python3.4/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

Same issue here:

2017-10-08 17:47:53 ERROR (MainThread) [homeassistant.components.camera.synology] Error when initializing SurveillanceStation
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/camera/synology.py", line 54, in async_setup_platform
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/synology/surveillance_station.py", line 9, in __init__
    self._api = Api(url, username, password, timeout, verify_ssl)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 57, in __init__
    self._initialize_api_sid()
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 83, in _initialize_api_sid
    response = self._get_json(api['url'], payload)
  File "/usr/local/lib/python3.6/site-packages/synology/api.py", line 192, in _get_json
    raise ValueError('Invalid or failed response', content)
ValueError: ('Invalid or failed response', {'error': {'code': 400}, 'success': False})

I suspect its down to #9583 maybe @snjoetw can help.

Im going to try some different configurations and see if I can “make” it work.

Hey guys yes it’s due to my change, sorry about that. It should be fixed in 0.55.1. In the mean time, you can upgrade to python 0.36 as a workaround

Or add a custom_component with the fix till 0.55.1 is released.

1 Like

@arsaboo Is there a custom_component available as a temp fix for this until 55.1/56.0?

If so, can you please provide your fix, cheers.

Just add this synology.py file to custom_components/camera/

@arsaboo perfect, working again as normal.

Many thanks.

Hi @snjoetw, can you please include in the “/usr/local/lib/python3.6/site-packages/synology/surveillance_station.py” the settings for motion detection by camera as well, at the moment is disabled or by surveillance station. Thanks a lot

Can you elaborate a bit? What kind of settings do you want to expose?

Right now you can already enable/disable motion detection from HASS for Synology cameras

Hi, thanks for getting back to me.
In the surveillance_station.pyfile you can import from api.py the “MOTION_DETECTION_SOURCE_BY_CAMERA” at line 1
and at the end of the file add
" def motion_detection_camera(self, camera_id):
“”“Disable motion detection for camera matching camera_id.”""
self._api.camera_event_md_param_save(
camera_id,
source=MOTION_DETECTION_SOURCE_BY_CAMERA)"

To avoid confusion, at line 44 change “enable_motion_detection” to “motion_detection_surveilance”.
the result will have 3 services:
“motion_detection_surveilance”
“disable_motion_detection”
“motion_detection_camera”

Thanks

I am on hass/1.2.1 and Synology/DSM 6.1.5-15254

The error I got is

requests.exceptions.InvalidSchema: No connection adapters were found for ‘192.168.1.8:5000/webapi/query.cgi’

what have I done wrong?