core: Latest QTS 4.5.4 breaks Qnap integration
The problem
Last night I’ve installed latest QTS available (4.5.4.1715 build 20210630) on my QNAP TS653A nas. Since then the network_tx and network_rx sensors have disappeared.
In addition, the other sensors of the Qnap integration only provide data at boot or reboot time. After that they no longer update. In other words, the Qnap integration is no longer able to monitor the health of the NAS.
Edit: On 17/07/2021, I’ve updated both my NAS (to the latest QTS 4.5.4.1723 build 20210708) and my HassOS (to 2021.7.3) but the issue is still there …
Edit #2: On 30/07/2021, I’ve updated my NAS to the latest QTS 4.5.4.1741 build 20210726. The integration is still broken …
What is version of Home Assistant Core has the issue?
since core-2021.6.6 to the latest core-2021.7.3
What was the last working version of Home Assistant Core?
core-2021.6.6
What type of installation are you running?
Home Assistant OS
Integration causing the issue
QNAP integration
Link to integration documentation on our website
https://www.home-assistant.io/integrations/qnap/
Example YAML snippet
#################
# Qnap Platform #
#################
- platform: qnap
host: 192.168.**.** #edited
port: !secret port_TS653A
username: !secret user_TS653A
password: !secret pw_TS653A
#verify_ssl: true
monitored_conditions:
- status
- cpu_usage
- cpu_temp
- system_temp
- memory_percent_used
- network_link_status
- network_rx
- network_tx
- volume_percentage_used
- drive_smart_status
Anything in the logs that might be useful for us?
Logger: homeassistant.components.qnap.sensor
Source: components/qnap/sensor.py:197
Integration: qnap (documentation, issues)
First occurred: 15:57:54 (1 occurrences)
Last logged: 15:57:54
Failed to fetch QNAP stats from the NAS
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/qnap/sensor.py", line 197, in update
self.data["bandwidth"] = self._api.get_bandwidth()
File "/usr/local/lib/python3.8/site-packages/qnapstats/qnap_stats.py", line 290, in get_bandwidth
default = resp["bandwidth_info"]["df_gateway"]
KeyError: 'bandwidth_info'
Logger: homeassistant.components.sensor
Source: components/qnap/sensor.py:288
Integration: Sensore (documentation, issues)
First occurred: 15:57:54 (2 occurrences)
Last logged: 15:57:54
Error adding entities for domain sensor with platform qnap
Error while setting up qnap platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 615, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 368, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 402, in _async_write_ha_state
state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 374, in _stringify_state
state = self.state
File "/usr/src/homeassistant/homeassistant/components/qnap/sensor.py", line 288, in state
data = self._api.data["bandwidth"][self.monitor_device]
KeyError: 'bandwidth'
### Additional information
_No response_
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 47 (9 by maintainers)
I have been experiencing the same issue. It appears the endpoint that the upstream library (python-qnapstats) uses for pulling bandwidth info has changed. I have raised an issue on the upstream library, but I am not sure how active the maintainer is.
After examining the code it should be fairly easy to suppress the error message (to stop it filling the logs), but obviously this wont restore the functionality.
I’m halfway through developing a code fix in the underlying qnapstats package, i’ve just got to revive an older qnap I have to be able to test the code against 4.5.3 and 4.5.4 (pre and post the breaking change).
So far I have not been able to get a response from the original package author. I’m going to finish authoring my changes and submit a pull request to see if I can get a response. Otherwise we’ll have to look at whether we need to fork the package (i’m not familiar with how such things usually work in the Python world). I will post back here when I make some progress.
Home Assistant Core 2021.8.7 is out. I double checked and fix works for my QNAP runnning 4.5.4, so this issue can be closed 🙂
@jonathanicq this fix will be included in Home Assistant version 2021.8.7
A fix has been submitted via PR #54571. Thank you to everyone who pitched in on this!
I’ll hopefully have some free time on the weekend. All being equal I’ll dig out my scratch code and look at cleaning it up and submitting a PR to the upstream library.
On Wed, Aug 11, 2021, at 6:37 AM, colinodell wrote:
Hey everyone, package author here. My apologies for not jumping into the conversation sooner. I no longer actively maintain the package, as I no longer use this integration myself. @julien-bouquet has graciously offered to assist with maintaining this package moving forward, and if everyone else has interest in assisting please leave a note here: https://github.com/colinodell/python-qnapstats/issues/43
That being said, I’m more than happy to review/merge PRs and tag new releases, but I likely won’t be doing any further coding on the
qnapstats
library or HA integration myself, so anything the community can do to help push those changes forward would be very welcome!!I’m experiencing the same issue after upgrading from 21.6.6 --> 21.7.3
Has this problem been confirmed ? Did anyone find a solution or workaround? I also noticed that the following curl command, which used to yield ‘200’ now instead result in ‘403’:
curl -s -o /dev/null -w "%{http_code}" http://192.168.0.XX
But I do not know if these issues are in any way related.I activated 2 Step on NAS but not so sure if this impacted the integration. All of my monitored QNAP sensors are not being set up. QTS 4.5.4.1723 build 20210708 currently installed on NAS
Thank you all very much guys!
@gralin Thank you for the update, it’s so nice the level of professionalism that we have from all members of this community.
Thank you ALL for that.
@jonathanicq The maintainers have reviewed and merged in https://github.com/home-assistant/core/pull/54571. The fix will therefore be included in their next release, which you would update to once it’s available.
@oywino The
bandwidth_info
issue reported here can also be found at https://github.com/colinodell/python-qnapstats/issues/60. If/when somebody submits a working PR to resolve this I will gladly merge it and tag a new release. Unfortunately, I no longer have the bandwidth to debug and fix these issues myself, so I’m really hoping that somebody in the community can step up and help us here 😃HTTP response should be 200. This is just a way to check if a web server is responding and alive. I don’t think this has anything to do with the OP subject. It was just a question I had. Sorry for hijacking the thread.
I am still hoping someone can find a way to restore the QNAP integration which seems permanently broken after the most recent QTS update.
Following the development of the discussion I tried again to run that curl command by entering the correct port (for safety reason I don’t use the default ports). On the http connection the result is 200% With https it is 000%
I wonder if we are getting closer or further from solving the problem
@oywino For the
curl -s -o /dev/null -w "%{http_code}" http://192.168.0.XX
question, changing mine tohttps://
doesn’t yield any result, nor does appending the port (:443
in my case). Oddly I get no output whatsoever. HTTP works – 403 w/o the port and I see 302 with:8080
appended – but that isn’t going to be relevant to my qnap integration in HA… or shouldn’t. 😅I checked this from inside of my HA container.
Unrelated, @sam-ward can you link to your upstream library issue? Maybe if we all go +1 it…
@gralin, You are right - adding 8080 to the URL solves this problem, and obviously this has to do with the change QNAP made with regards to redirecting. Thank you for pointing me in the right direction. @ChrisRomp, obviously - if you choose to use SSL on servers in a Local Area Network (which I fail to see the point in), then it will work. But I do not use SSL when accessing anything on my LAN, and I don’t think I ever will. After all, no alien visitors have access to my LAN so there’s nothing to protect against.
@gralin That doesn’t apply to mine; it’s HTTPS on 443 with CA-signed certs.
@oywino @liuk4friends After this firmware upgrade I need to suffix the address of my QNAP with :8080 which is the used for the portal. I think your curl query would work if you did the same. I guess in previous version there was a redirect or it was also working on port 80?
I’ve two TS-451+ with firmware 4.5.4.1723 However, one everything but the network down/up and the other, is completely at dark (all sensors has gone)
I didn’t active 2 step verification,but same issue happend
Hi, I also updated to 4.5.4.1723 and have lost the sensors… as I had also activated 2 step verification, I thought it was due to the 2 step verification… let´s see if someone is able to correct this inconvenience !
Same here, but i have no bandwith monitpring active: