Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to fetch QNAP stats from the NAS #31994

Closed
andilge opened this issue Feb 19, 2020 · 21 comments
Closed

Failed to fetch QNAP stats from the NAS #31994

andilge opened this issue Feb 19, 2020 · 21 comments

Comments

@andilge
Copy link

andilge commented Feb 19, 2020

The problem

Constant failures fetching QNAP stats from the NAS

Environment

  • Home Assistant release: 0.105.5
  • Operating environment: Hass.io
  • Python release: Python 3.7.6
  • Component/platform: QNAP

Problem-relevant configuration.yaml

- platform: qnap
  host: !secret qnap_lan_ip
  port: 446
  ssl: true
  verify_ssl: false
  username: !secret qnap_username
  password: !secret qnap_password
  monitored_conditions:
  - status
  - cpu_usage
  - memory_percent_used
  - volume_percentage_used
  - cpu_temp
  - system_temp
  - network_link_status
  - network_tx
  - network_rx
  - drive_smart_status
  - drive_temp
  - volume_percentage_used

Traceback/Error logs

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/qnap/sensor.py", line 191, in update
    self.data["system_stats"] = self._api.get_system_stats()
  File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 207, in get_system_stats
    force_list=("DNS_LIST")
  File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 67, in _get_url
    self._init_session()
  File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 49, in _init_session
    if self._login() is False:
  File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 57, in _login
    result = self._execute_post_url("authLogin.cgi", data, False)
  File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 98, in _execute_post_url
    return self._handle_response(resp, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 110, in _handle_response
    data = xmltodict.parse(resp.content, force_list=force_list)['QDocRoot']
  File "/usr/local/lib/python3.7/site-packages/xmltodict.py", line 173, in parse
    handler = _DictSAXHandler(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'force_list'

Additional information

I've seen this error on with previous firmware QTS 4.4.1.1146 build 20191206 and now, after update to most recent with QTS 4.4.1.1216 build 20200214.

@probot-home-assistant
Copy link

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

@springstan
Copy link
Member

Thanks for filling out the issue template! 👍

@andilge
Copy link
Author

andilge commented Feb 19, 2020

never mind, thx for pointing in the right direction.

forgot to put

@chezpaul
Copy link

chezpaul commented Feb 20, 2020

I have the same problem with Home Assistant release: 0.105.5
Operating environment: Hass.io on a Pi4

QNAP
sensor:

  • platform: qnap
    host: 192.168.1.44
    username: !secret qnap_username
    password: !secret qnap_password
    timeout: 15
    verify_ssl: false
    monitored_conditions:
    • status
    • cpu_usage
    • memory_percent_used
    • network_tx
    • volume_percentage_used

I own a QNAP TS251 with latest firmware.

@colinodell
Copy link
Contributor

This error is coming from the xmltodict functionality that the underlying qnapstats library uses.

TypeError: __init__() got an unexpected keyword argument 'force_list'

I don't understand why this would be suddenly failing. Is HASS now using a different version of xmltodict which no longer has this force_list feature? I'm currently on holiday without my laptop, so if anyone could help check into this I'd appreciate it!

@springstan
Copy link
Member

Not as far as I can tell, it is not a requirement for HA.
It is for some integrations though:
https://github.com/home-assistant/home-assistant/blob/ce710f1e0bce31404bdd8627452504ee050ab40b/requirements_all.txt#L2097-L2103

However, this version conforms with the requirements for qnapstats (xmltodict>=0.10.0)

@colinodell
Copy link
Contributor

Thanks for checking on that, @springstan. I re-ran the qnapstats test suite and can confirm all tests are passing with xmltodict version 0.12.0

I also tried to replicate this issue using @chezpaul's configuration but cannot - everything works as expected. (FWIW I'm using the alternative install method of HA Supervised on a generic Linux host myself, not on a Pi)

@chezpaul or @andilge - could one of you please run pip show xmltodict and pip show qnapstats to confirm which versions of both libraries your instance is running? You should have 0.12.0 and 0.2.7 respectively.

@andilge
Copy link
Author

andilge commented Feb 24, 2020

@colinodell on my RasPi 3+ pip isn't installed, I assume you want me to run the command on the QNAP, right?

Just tried enter QNAP with bash shell and got 3 times credential mismatch (no idea why). Now my laptop's IP is banned for 24 hours. I will have to retry tomorrow. I can't temporarily dis-activate the IP filter even with QNAP admin account, it refuses to accept this config @@ Somebody interested in buying that device, I get really pi***d off by it.

Like chezpaul, I use model TS-251.

@aidbish
Copy link
Contributor

aidbish commented Feb 27, 2020

@colinodell

Hi I ran those commands on my install of HA (docker install) and got the following results which are different to what you believe it should be

bash-5.0# pip show xmltodict
Name: xmltodict
Version: 0.4
Summary: Makes working with XML feel like you are working with JSON
Home-page: https://github.com/martinblech/xmltodict
Author: Martin Blech
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.7/site-packages
Requires:
Required-by: qnapstats, pyvizio, pytfiac, pysonos, PyMetno, pymediaroom, pizzapi, meteoalertapi, ibmiotf, huawei-lte-api, greenwavereality, georss-client, buienradar, aio-georss-client
bash-5.0# pip show qnapstats
Name: qnapstats
Version: 0.3.0
Summary: Python API for obtaining QNAP NAS system stats
Home-page: https://github.com/colinodell/python-qnapstats
Author: Colin O'Dell
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.7/site-packages
Requires: xmltodict, requests
Required-by:
bash-5.0#

@aidbish
Copy link
Contributor

aidbish commented Feb 27, 2020

further info

ran pip install qnapstats and this reinstalled qnapstats version 3 but upgraded xmltodict to version 0.12.0
did a restart and issue persisted

ran pip install qnapstats==0.2.7
restarted and now there are no error messages and stats from qnap are again working

But i understand on next upgrade this will be reverted

@chezpaul
Copy link

I also updated using pip to 0.3.0 and 0.12.0 but I still get an error.

2020-02-28 11:06:46 ERROR (SyncWorker_3) [homeassistant.components.qnap.sensor] Failed to fetch QNAP stats from the NAS Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/qnap/sensor.py", line 191, in update self.data["system_stats"] = self._api.get_system_stats() File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 207, in get_system_stats force_list=("DNS_LIST") File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 67, in _get_url self._init_session() File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 49, in _init_session if self._login() is False: File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 57, in _login result = self._execute_post_url("authLogin.cgi", data, False) File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 98, in _execute_post_url return self._handle_response(resp, **kwargs) File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 112, in _handle_response auth_passed = data['authPassed'] KeyError: 'authPassed' 2020-02-28 11:06:46 WARNING (MainThread) [homeassistant.components.sensor] Platform qnap not ready yet. Retrying in 60 seconds.

@aidbish
Copy link
Contributor

aidbish commented Feb 29, 2020

@chezpaul that seems like a different error

i still had issues on 0.3.0 of qnapstats
try installing 0.2.7
pip install qnapstats==0.2.7

@chezpaul
Copy link

chezpaul commented Feb 29, 2020

Nope the didn't do the trick.
I get the same error.

2020-02-28 17:59:33 ERROR (SyncWorker_9) [homeassistant.components.qnap.sensor] Failed to fetch QNAP stats from the NAS Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/qnap/sensor.py", line 191, in update self.data["system_stats"] = self._api.get_system_stats() File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 207, in get_system_stats force_list=("DNS_LIST") File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 67, in _get_url self._init_session() File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 49, in _init_session if self._login() is False: File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 57, in _login result = self._execute_post_url("authLogin.cgi", data, False) File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 98, in _execute_post_url return self._handle_response(resp, **kwargs) File "/usr/local/lib/python3.7/site-packages/qnapstats/qnap_stats.py", line 112, in _handle_response auth_passed = data['authPassed'] KeyError: 'authPassed' 2020-02-28 17:59:33 WARNING (MainThread) [homeassistant.components.sensor] Platform qnap not ready yet. Retrying in 30 seconds.

And I confirm that I have 0.12.0 and 0.2.7 respectively running

@chezpaul
Copy link

chezpaul commented Mar 1, 2020

Is there anything I need to do on the Qnap side that I missed maybe?

@aidbish
Copy link
Contributor

aidbish commented Mar 1, 2020

i didnt have to touch qnap

@larserhardsen
Copy link

I also see the issue on my docker based installation.
I can confirm that I have xmltodict 0.12.0 and qnapstats 0.2.7 and see the TypeError: __init__() got an unexpected keyword argument 'force_list' in the log.

@larserhardsen
Copy link

I think I found the reason. Some days ago I installed the hpprinter component from HACS, and today I updated it. The release notes stated that the upgrade consisted of an upgrade to the xmldict library, from 0.4 (or so) to 0.12 - after this, the QNAP sensors works again.

@aidbish
Copy link
Contributor

aidbish commented Mar 10, 2020

@larserhardsen Good catch, can confirm this is the case here.
I also had the HP printer integration installed. did the update and all working ok

@springstan
Copy link
Member

@andilge has this solved your problem as well?

@andilge
Copy link
Author

andilge commented Mar 10, 2020

Hi all,

I did have the hp printer integration installed from HACS when reporting. In the mean time I've reinstalled HA from zero, have now reactivated QNAP installation and it works fine. After adding HP printer integration form HACS again I see both integrations work fine.

Yes, my problem has been solved. I'll close this Issue.

@andilge andilge closed this as completed Mar 10, 2020
@chezpaul
Copy link

chezpaul commented Mar 11, 2020

Maybe I should just add the HP Printer integration even though I don't have an HP printer. ;-)
@larserhardsen you said you had 0.12 and then you said you upgraded from 0.4 to 0.12 so which was it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants