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.64k stars 30.79k forks source link

Qnap Integration #42732

Closed JPOliveGit closed 3 years ago

JPOliveGit commented 4 years ago

The problem

Failed to fetch QNAP stats from the NAS

Environment

Home Assistant 0.117.0

https://www.home-assistant.io/integrations/qnap/

Problem-relevant configuration.yaml

########################################

QNAP

########################################

Traceback/Error logs

Detalhes do log ( ERROR ) Logger: homeassistant.components.qnap.sensor Source: components/qnap/sensor.py:194 Integration: qnap (documentation, issues) First occurred: 22:52:37 (7 occurrences) Last logged: 23:03:38

Failed to fetch QNAP stats from the NAS Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 159, in _new_conn conn = connection.create_connection( File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 61, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen httplib_response = self._make_request( File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request self._validate_conn(conn) File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn conn.connect() File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 309, in connect conn = self._new_conn() File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 171, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0xac0658e0>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 726, in urlopen retries = retries.increment( File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 446, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='http', port=443): Max retries exceeded with url: //192.168.1.###:69/cgi-bin/authLogin.cgi (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xac0658e0>: Failed to establish a new connection: [Errno -3] Try again'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/qnap/sensor.py", line 194, in update self.data["system_stats"] = self._api.get_system_stats() File "/usr/local/lib/python3.8/site-packages/qnapstats/qnap_stats.py", line 205, in get_system_stats resp = self._get_url( File "/usr/local/lib/python3.8/site-packages/qnapstats/qnap_stats.py", line 67, in _get_url self._init_session() File "/usr/local/lib/python3.8/site-packages/qnapstats/qnap_stats.py", line 49, in _init_session if self._login() is False: File "/usr/local/lib/python3.8/site-packages/qnapstats/qnap_stats.py", line 57, in _login result = self._execute_post_url("authLogin.cgi", data, False) File "/usr/local/lib/python3.8/site-packages/qnapstats/qnap_stats.py", line 97, in _execute_post_url resp = self._session.post(url, data, timeout=self._timeout, verify=self._verify_ssl) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 578, in post return self.request('POST', url, data=data, json=json, kwargs) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 530, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 643, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='http', port=443): Max retries exceeded with url: //192.168.1.###:69/cgi-bin/authLogin.cgi (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xac0658e0>: Failed to establish a new connection: [Errno -3] Try again'))

Additional information

qnapstat installed via terminal

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

Hey there @colinodell, mind taking a look at this issue as its been labeled with an integration (qnap) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

colinodell commented 4 years ago

Can you confirm whether you have a valid SSL certificate on port 69 of your QNAP device?

tannertidus commented 4 years ago

Hi, same problem.

My QNAP works and is lisening on http://192.168.0.166:8082/cgi-bin/

I have a dock that wkorks and is lisening on http://192.168.0.166:8123/

My configuration is:

In my home assistant log: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/qnap/sensor.py", line 194, in update self.data["system_stats"] = self._api.get_system_stats() File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 267, in get_system_stats for dns in root["dnsInfo"]["DNS_LIST"]: TypeError: 'NoneType' object is not subscriptable

Any idea?

Thanks!!

colinodell commented 4 years ago

Hi @tannertidus, it looks like you're experiencing a different error message where it connects just fine but has trouble reading some of the information.

Can you confirm that your QNAP model is listed on https://github.com/colinodell/python-qnapstats#device-support as a supported model? If not, and you'd be interested in helping us add support, please run the debug.py script and create a new issue on the qnapstats project so we can help add that missing support.

tannertidus commented 4 years ago

Hi!!

Is not listed :( My qnap is TS-328, Version 4.5.1.1465

The output:

(pruebas) D:\Proyectos\Python\HomeAssistant>python debug.py Host (prefix with 'https://' if needed): 192.168.0.166 Port: 8082 Username: homeassistant Password: DEBUG: Creating new session DEBUG: POST to URL: http://192.168.0.166:8082/cgi-bin/authLogin.cgi DEBUG: Request executed: 200 DEBUG: Response Text: <?xml version="1.0" encoding="UTF-8" ?>

<![CDATA[]]>

DEBUG: GET from URL: http://192.168.0.166:8082/cgi-bin/management/manaRequest.cgi?subfunc=sysinfo&hd=no&multicpu=1 DEBUG: Appending access_token (SID: 2r05cp8y) to url DEBUG: Request executed: 200 DEBUG: Response Text: <?xml version="1.0" encoding="UTF-8" ?>

1 0 3 eth0 Adapter 1 48453 52833 0 1 1000 0 192.168.0.166 255.255.255.0 24:5e:be:20:e6:ce STATIC 02 eth1 Adapter 2 0 0 0 0 1000 0 0.0.0.0 0.0.0.0 24:5e:be:20:e6:cf DHCP 1 38 100 1 SYS FAN 690 0 0 -1 0 -1 NAS Q186B07206

("'NoneType' object is not subscriptable",) Traceback (most recent call last): File "debug.py", line 14, in qnap.get_system_stats() File "C:\Users\Rafa\anaconda3\envs\pruebas\lib\site-packages\qnapstats\qnap_stats.py", line 267, in get_system_stats for dns in root["dnsInfo"]["DNS_LIST"]: TypeError: 'NoneType' object is not subscriptable DEBUG: GET from URL: http://192.168.0.166:8082/cgi-bin/management/manaRequest.cgi?subfunc=sysinfo&sysHealth=1 DEBUG: Appending access_token (SID: 2r05cp8y) to url DEBUG: Request executed: 200 DEBUG: Response Text: <?xml version="1.0" encoding="UTF-8" ?>

1

DEBUG: GET from URL: http://192.168.0.166:8082/cgi-bin/disk/qsmart.cgi?func=all_hd_data DEBUG: Appending access_token (SID: 2r05cp8y) to url DEBUG: Request executed: 200 DEBUG: Response Text: <?xml version="1.0" encoding="UTF-8" ?>

1

DEBUG: GET from URL: http://192.168.0.166:8082/cgi-bin/management/chartReq.cgi?chart_func=disk_usage&disk_select=all&include=all DEBUG: Appending access_token (SID: 2r05cp8y) to url DEBUG: Request executed: 200 DEBUG: Response Text: <?xml version="1.0" encoding="UTF-8" ?>

1

DEBUG: GET from URL: http://192.168.0.166:8082/cgi-bin/management/chartReq.cgi?chart_func=QSM40bandwidth DEBUG: Appending access_token (SID: 2r05cp8y) to url DEBUG: Request executed: 200 DEBUG: Response Text: <?xml version="1.0" encoding="UTF-8" ?>

1

Thanks!!

JPOliveGit commented 3 years ago

Hey there @colinodell, no i don't have an SSL but i turned to false ssl and it does the same

colinodell commented 3 years ago

@JPOliveGit Looking closer at your stack trace I'm seeing the following error:

socket.gaierror: [Errno -3] Try again

According to StackOverflow, a gaierror means that the hostname is invalid. Please double-check that your qnap_ip secret exists and has a valid value.

JPOliveGit commented 3 years ago

@colinodell finally i made it work, the problem was that I defined a different port on the nas and it wasn't able to handle it i restored the port to the original configuration and now it works