home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.67k stars 30.8k forks source link

DSM integration not working when running docker package on Synology #46724

Closed Shemmmy closed 3 years ago

Shemmmy commented 3 years ago

The problem

All entities of DSM integration become inaccessible if the docker package is running on sinology At the same time, if the docker package is stopped, the DSM integration starts without errors and all entities are available.

What is version of Home Assistant Core has the issue?

core-2021.2.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

DSM

Link to integration documentation on our website

No response

Example YAML snippet

# Put your YAML below this line

Anything in the logs that might be useful for us?

# Put your logs below this line

Logger: homeassistant.config_entries Source: components/synology_dsm/init.py:459 First occurred: 11:22:38 AM (1 occurrences) Last logged: 11:22:38 AM

Error setting up entry 192.168.41.3 for synology_dsm Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 239, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/usr/src/homeassistant/homeassistant/components/synology_dsm/init.py", line 186, in async_setup_entry await api.async_setup() File "/usr/src/homeassistant/homeassistant/components/synology_dsm/init.py", line 336, in async_setup await self.async_update() File "/usr/src/homeassistant/homeassistant/components/synology_dsm/init.py", line 459, in async_update await self._hass.async_add_executor_job( File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, self.kwargs) File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 347, in update self._surveillance.update() File "/usr/local/lib/python3.8/site-packages/synology_dsm/api/surveillance_station/init.py", line 42, in update live_view_datas = self._dsm.get( File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 204, in get return self._request("GET", api, method, params, kwargs) File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 271, in _request raise SynologyDSMAPIErrorException( synology_dsm.exceptions.SynologyDSMAPIErrorException: {'api': 'SYNO.SurveillanceStation.Camera', 'code': 401, 'reason': 'Invalid parameter', 'details': None}

Hi! I have running HA on Raspberry PI 4B And my synology DS 412+ running on last version DSM 6.2.3-25426 Update 3

Shemmmy commented 3 years ago

And of course, the integration account has full access rights with administrator privileges

probot-home-assistant[bot] commented 3 years ago

synology_dsm documentation synology_dsm source (message by IssueLinks)

probot-home-assistant[bot] commented 3 years ago

Hey there @hacf-fr, @quentame, @mib1185, mind taking a look at this issue as its been labeled with an integration (synology_dsm) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

mib1185 commented 3 years ago

Hi @Shemmmy

the error message indicates an issue on interacting with Surveillance Station. Do you encounter any issues with Surveillance Station when starting docker package on DSM?

Shemmmy commented 3 years ago

Hello!

No, i don't have any problems with SS. It works stably whether docker is running or not.

mib1185 commented 3 years ago

Could you provide a more detailed workflow (step by step)

Shemmmy commented 3 years ago

Okay, I'll try to describe in steps.

  1. Synology is on and running. The SS is also on and working, the cameras are recording video. Docker package stopped.
  2. I turn on HA on my raspberri.
  3. The integration of synology_dsm successfully connects to synology, pulls out a bunch of entities, all of them are available in HA (utilization of resources, cameras, etc.). There are no errors in the integration of sinology_dsm in the HA log. Everything works well.
  4. I turn on the docker package on synology. Docker is empty, there are no containers in it. I reboot HA.
  5. In HA all entities created by the integration of synology_dsm receive the status "unavailable" and in the HA log the errors given above.
  6. I stop the docker package on synology, and restart the HA. Now you can go to step 3, everything is repeated cyclically.
mib1185 commented 3 years ago

Thanks for detailed explanations, this will help to reproduce it. One last question, due to ds 412+ has two LAN interfaces - how is your network setup?

Shemmmy commented 3 years ago

DS connected via eth1 only.

mib1185 commented 3 years ago

Unfortunately I can't reproduce the issue. But I have to note, that I already use a newer version from #46113 . If you would like to also test this version, please follow one of this small howto:

Option 1) create the dir customer_components under your config dir, than copy the whole synology_dsm dir from my branch into the customer_components dir ... result should look like

config
|-- configuration.yaml
|-- custom_components
|   `-- synology_dsm
|       |-- __init__.py
(...)

In addition please enable debug logging for synology_dsm and stream component integration by adding the following into your configuration.yaml:

logger:
  default: info
  logs:
    custom_components.synology_dsm: debug
    homeassistant.components.stream: debug

Option 2) Use the following docker image: docker pull mib85/homeassistant:synology-dsm_fix-service

pervolianinen commented 3 years ago

Unfortunately I can't reproduce the issue. But I have to note, that I already use a newer version from #46113 . If you would like to also test this version, please follow one of this small howto:

Hi! Not work with HA in docker when using HOST network. Work fine when docker network is bridge. If i use integration from HA 2021.1.5 get error Faild authorization If i use "Option 1)"? component create but has no properties and States In log no information.

mib1185 commented 3 years ago

Hi @pervolianinen meanwhile the mentioned PR #46113 is merged and will be part of the upcoming 2021.3 release. So if you want simple wait for next release and test again with that 😉

pervolianinen commented 3 years ago

Hi @pervolianinen meanwhile the mentioned PR #46113 is merged and will be part of the upcoming 2021.3 release. So if you want simple wait for next release and test again with that 😉

the mentioned PR #46113 is not working if use host network in docker, HA 2021.1.5 work fine with bridge network.

mib1185 commented 3 years ago

This PR does not have any impact to the network behaviour of HA, because it is part of the core it self, but not the integration. If you have more detailed informations about the issue you are seeing, than please provide them.

Because the (dev) docker image of #46133 was based on dev branch, it might be possible, that there were changes included, which causes issue with HOST network docker. But this is all part of HA core.

pervolianinen commented 3 years ago

This PR does not have any impact to the network behaviour of HA, because it is part of the core it self, but not the integration. If you have more detailed informations about the issue you are seeing, than please provide them.

Because the (dev) docker image of #46133 was based on dev branch, it might be possible, that there were changes included, which causes issue with HOST network docker. But this is all part of HA core.

  1. When use doker HA 2021.1.5 with bridge network integration synology dsm work fine. 2.1 When use doker with host network with HA 2021.1.5 integration synology dsm has error faild autorization 2.2 When use doker with host network with HA 2021.1.5 AND PR #46113 integration creating but has no status, propertis and etc.
mib1185 commented 3 years ago

Do you have any logs and/or screenshots and in addition could you describe your setup a little bit more detailed (which deyployment method did you use for HA, where is it installed, how is your network setup, ...)

pervolianinen commented 3 years ago

Do you have any logs and/or screenshots and in addition could you describe your setup a little bit more detailed (which deyployment method did you use for HA, where is it installed, how is your network setup, ...)

  1. In logs in 2.1 - failed autorization. In 2.2. no information.
  2. I use HA 2021.1.5 in docker from https://www.home-assistant.io/installation/
  3. Docker work on synology ds218+ with dsm 6.2.3.
  4. Docker for HA use host network (not bridge).
mib1185 commented 3 years ago

Hi, meanwhile 2021.3 is released with contain the latest code changes for Synology DSM integration. Please check if your issue still persists with this version.

Shemmmy commented 3 years ago

Hi! issie still persists. HA build 2021.3.2 Synology 6.2.4-25554 (SS version 8.1.3-5473)

Log: Logger: homeassistant.config_entries Source: components/synology_dsm/init.py:564 First occurred: 1:43:20 PM (1 occurrences) Last logged: 1:43:20 PM

Error setting up entry 192.168.41.3 for synology_dsm Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 248, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/usr/src/homeassistant/homeassistant/components/synology_dsm/init.py", line 192, in async_setup_entry await api.async_setup() File "/usr/src/homeassistant/homeassistant/components/synology_dsm/init.py", line 419, in async_setup await self.async_update() File "/usr/src/homeassistant/homeassistant/components/synology_dsm/init.py", line 564, in async_update await self._hass.async_add_executor_job( File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, self.kwargs) File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 347, in update self._surveillance.update() File "/usr/local/lib/python3.8/site-packages/synology_dsm/api/surveillance_station/init.py", line 42, in update live_view_datas = self._dsm.get( File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 204, in get return self._request("GET", api, method, params, kwargs) File "/usr/local/lib/python3.8/site-packages/synology_dsm/synology_dsm.py", line 271, in _request raise SynologyDSMAPIErrorException( synology_dsm.exceptions.SynologyDSMAPIErrorException: {'api': 'SYNO.SurveillanceStation.Camera', 'code': 401, 'reason': 'Invalid parameter', 'details': None}

mib1185 commented 3 years ago

Hi @Shemmmy could you please enable debug logging (as described in https://github.com/home-assistant/core/issues/46724#issuecomment-781603097) and provide all logs related to synology_dsm integration?

Shemmmy commented 3 years ago

Hi @mib1185 I apologize for the delay in answering. A network called 'hassio' was created in docker settings. After removing this network, everything works fine. I think the network was created by the hass.io package after experimenting with running HA in docker on my synology.

chemelli74 commented 3 years ago

@Shemmmy if issue is solved, please consider closing it. Thx

Simone