Synology Surveillance Station IP Camera

Hi @runevad,

I tried to use your method, so in my configuration.yaml i have this:

 #Synology Home Mode
rest_command:
  ss_enable_home:
    url: !secret home_mode_on
    method: get
  ss_disable_home:
    url: !secret home_mode_off
    method: get

In my secrets.yaml file i have the both urls, that works, because when i do it by my firefox, i see that home mode turn off and on.

#Home mode on
home_mode_on: https://192.168.1.100:7001/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=true&_sid=E9POXXXXXXXXXXXXXXXX
#Home mode off
home_mode_off: https://192.168.1.100:7001/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&off=true&_sid=E9POXXXXXXXXXXXXXXXX

And then i have my automation:

alias: Desactivar Disp No Presencia
hide_entity: True
initial_state: 'on'
trigger:
  platform: state
  entity_id: group.track_casa
  from: 'home'
  to:  'not_home'
condition:
  - condition: state
    entity_id: input_boolean.suegros_casa
    state: 'off'  
action:
  - service: homeassistant.turn_off
    entity_id: group.regleta_dormitorio
  - service: switch.turn_off
    entity_id: switch.enchufe_tv
  - service: switch.turn_off
    entity_id: switch.00117477dc4f22c971de_4
  - service: switch.turn_off
    entity_id: switch.deco_ruso
  - service: switch.turn_off
    entity_id: switch.tele
  - service: switch.turn_off
    entity_id: switch.enchufe_cocina
  - service: rest_command.ss_disable_home
  - service: notify.telegram
    data_template:
      title: "Casa: "
      message: "Dispositivos OFF, Home Mode ON"

So when i go out from home, all devices of automation, turn off, but the service rest_command don’t works and also the telegram notification does’t work.

In my logs, i can see this:

2019-02-04 19:26:29 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.activar_disp_presencia. Unknown error for call_service at pos 7:
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 924, in _wrap_create_connection
await self._loop.create_connection(*args, **kwargs))
File “uvloop/loop.pyx”, line 1945, in create_connection
File “uvloop/loop.pyx”, line 1942, in uvloop.loop.Loop.create_connection
File “uvloop/handles/stream.pyx”, line 977, in uvloop.loop.__uv_stream_buffered_on_read
File “uvloop/sslproto.pyx”, line 367, in uvloop.loop.SSLProtocol.buffer_updated
File “uvloop/sslproto.pyx”, line 483, in uvloop.loop.SSLProtocol._do_handshake
File “/usr/local/lib/python3.6/ssl.py”, line 694, in do_handshake
match_hostname(self.getpeercert(), self.server_hostname)
File “/usr/local/lib/python3.6/site-packages/idna_ssl.py”, line 19, in patched_match_hostname
return real_match_hostname(cert, hostname)
File “/usr/local/lib/python3.6/ssl.py”, line 331, in match_hostname
% (hostname, dnsnames[0]))
ssl.CertificateError: hostname ‘192.168.1.100’ doesn’t match ‘my.domain.com

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/src/app/homeassistant/components/rest_command.py”, line 101, in async_service_handler
headers=headers
File “/usr/local/lib/python3.6/site-packages/aiohttp/client.py”, line 476, in _request
timeout=real_timeout
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 522, in connect
proto = await self._create_connection(req, traces, timeout)
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 854, in _create_connection
req, traces, timeout)
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 992, in _create_direct_connection
raise last_exc
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 974, in _create_direct_connection
req=req, client_error=client_error)
File “/usr/local/lib/python3.6/site-packages/aiohttp/connector.py”, line 927, in _wrap_create_connection
req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host 192.168.1.100:7001 ssl:True [CertificateError: (“hostname ‘192.168.1.100’ doesn’t match ‘my.domain.com’”,)]

Someone can help me with this?

thanks

You can’t use that SID in your url, it is always different

Hi @pergola.fabio,

Thanks for reply. so then which solution can i use to enable/disable home mode when i go out?

Well, I use the .py version that can be found in this thread, or on your Synology you can create 2 actions to turn it on or off, that creates an http url, you can call that url with a curl command

@pergola.fabio

I tried to use the .py script version and when i execute command:

python3 /config/synology_home_mode.py status

i get this error (same as in my first option) in my logs:

root@homeassistant-0:/usr/src/app# python3 /config/synology_home_mode.py status
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 364, in connect
_match_hostname(cert, self.assert_hostname or server_hostname)
File “/usr/local/lib/python3.6/site-packages/urllib3/connection.py”, line 374, in _match_hostname
match_hostname(cert, asserted_hostname)
File “/usr/local/lib/python3.6/ssl.py”, line 331, in match_hostname
% (hostname, dnsnames[0]))
ssl.CertificateError: hostname ‘192.168.1.100’ doesn’t match ‘my.domain.com

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=‘192.168.1.100’, port=7001): Max retries exceeded with
url: /webapi/auth.cgi?method=Login&account=MYUSER&passwd=MYPASSWORD%40&format=cookie&api=SYNO.API.Auth&version=2&sessi
on=SurveillanceStation (Caused by SSLError(CertificateError(“hostname ‘192.168.1.100’ doesn’t match ‘my.domain.com’”,),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/config/synology_home_mode.py”, line 33, in
login = session.get(BASE_URL + API_AUTH_FILE, params=LOGIN_PAYLOAD, timeout=5)
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 546, in get
return self.request(‘GET’, 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 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘192.168.1.100’, port=7001): Max retries exceeded with url:
/webapi/auth.cgi?method=Login&account=MYUSER&passwd=MYPASSWORD%40&format=cookie&api=SYNO.API.Auth&version=2&session=S
urveillanceStation (Caused by SSLError(CertificateError(“hostname ‘192.168.1.100’ doesn’t match ‘my.domain.com’”,),))

Tried http instead of https?

Hi,

Using http, works. Using https doesn’t.

seems somekind of ssl / certificate issue?
SurveillanceStation (Caused by SSLError(CertificateError(“hostname ‘192.168.1.100’ doesn’t match ‘my.domain.com’”,),))

i am using this command withhout an issue

command_on: 'curl -k "https://192.168.0.15:6003/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method="Trigger"&version=1&eventId=1&account=USER&password=PASS"'

Yes, seems that there is a problem using my certificate between HA and Synology… i need to investigate.

If i put this url in my firefox, i get an error using my credentials of IP, port, user and password.

imagen

good news guys, pull request for homemode!!

4 Likes

Hi,

Any news when will be integrated in HA?

Just load as a custom for now

Thanks for reply.

Where i can download this custom to test it?

thanks

here you see developer creating some custom files

feedback on github is verry welcome, we are testing those

Forgive me as I did not read the whole tread.
What Im seeing is a Memory leak when using the Synology component. 2gig in ~6 hour period. The HA process is at 99.3% memory usage. This causes HA to stop responding, forcing a manual stop, start of the HA service to bring HA back online. I’ve opened a bug track on this.

FYI - I had no issue with the streaming using this method.

no issues here with synology

I think I’ve seen the same (or similar) behaviour. Everything is fine if I just look at the “preview” of the camera feeds in the Home Assistant UI. But if I click any of my camera feeds to enlarge the image, memory usage on my Raspberry Pi increases relatively quickly. As a result of that, I start getting notifications on my phone from Home Assistant stating certain network devices (which I’m monitoring) have gone offline when they have not. The quick fix for me is to reboot the Raspberry Pi.

ah, thats why i dont see that memory leak? i actually dont watch the feeds in HA? i never click on the cameras, just watch the snapshots
ffmpeg v2.0 is coming in 91.0 , should be better and more speed, maybe this will fix it

@pergola.fabio how can we put this running?
Thanks!