Unexpected error fetching qnap data - after update to 2025.05. // TypeError: 'NoneType' object does not support the context manager protocol
The problem
Logger: homeassistant.components.qnap.coordinator Quelle: helpers/update_coordinator.py:380 Integration: QNAP (Dokumentation, Probleme) Erstmals aufgetreten: 8. Mai 2025 um 21:39:39 (532 Vorkommnisse) Zuletzt protokolliert: 09:18:58
Unexpected error fetching qnap data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 380, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py", line 86, in _async_update_data return await self.hass.async_add_executor_job(self._sync_update) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py", line 72, in _sync_update suppress_insecure_request_warning() if not self._verify_ssl else nullcontext() File "/usr/local/lib/python3.13/contextlib.py", line 141, in enter return next(self.gen) File "/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py", line 40, in suppress_insecure_request_warning with urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning): ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object does not support the context manager protocol
What version of Home Assistant Core has the issue?
core-2025.5.0
What was the last working version of Home Assistant Core?
core-2025.4.4
What type of installation are you running?
Home Assistant OS
Integration causing the issue
QNAP
Link to integration documentation on our website
https://www.home-assistant.io/integrations/qnap
Diagnostics information
2025-05-09 09:16:27.250 ERROR (MainThread) [homeassistant.components.qnap.coordinator] Unexpected error fetching qnap data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 380, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py", line 86, in _async_update_data return await self.hass.async_add_executor_job(self._sync_update) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py", line 72, in _sync_update suppress_insecure_request_warning() if not self._verify_ssl else nullcontext() File "/usr/local/lib/python3.13/contextlib.py", line 141, in enter return next(self.gen) File "/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py", line 40, in suppress_insecure_request_warning with urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning): ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object does not support the context manager protocol 2025-05-09 09:16:27.252 DEBUG (MainThread) [homeassistant.components.qnap.coordinator] Finished fetching qnap data in 0.002 seconds (success: False)
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response
Hey there @disforw, mind taking a look at this issue as it has been labeled with an integration (qnap) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of qnap can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign qnapRemoves the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
qnap documentation qnap source (message by IssueLinks)
Same issue for me with same version
same issue for me
same here with 2025.5
same here with 2025.5
This is a duplicate of issue #144023
I've managed to mitigate the issue and get my integration up and running again (for now) by changing the following lines in: /usr/src/homeassistant/homeassistant/components/qnap/coordinator.py
@contextmanager
def suppress_insecure_request_warning():
with urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning):
yield
with
@contextmanager
def suppress_insecure_request_warning():
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
try:
yield
finally:
pass # can't re-enable warnings, but this avoids crashing
I haven't tested if this works with SSL certificates. Always verify your code and make backups before running it.
Update: This does not work on core (HAOS) versions. This fixed works for Docker.
I've managed to mitigate the issue and get my integration up and running again (for now) by changing the following lines in: /usr/src/homeassistant/homeassistant/components/qnap/coordinator.py
[core-ssh ~]$ cd /usr/src/homeassistant/homeassistant/components/qnap/ -bash: cd: /usr/src/homeassistant/homeassistant/components/qnap/: No such file or directory
i only have these files:
[core-ssh ~]$ find / -type f -name "coordinator.py" 2>/dev/null /homeassistant/custom_components/hacs/coordinator.py /homeassistant/custom_components/battery_notes/coordinator.py
That path /usr/src/homeassistant/homeassistant/components/qnap/ to the file "coordinator.py" is in Haos?. I do not find it in my system.
Same problem for me, but I have two Qnap NAS: Only TS-228 with Firmware: 4.3.6 has the issue. The second NAS TS-216G with Firmware: 5.2.4 work without any problems.
Unfortunately is not possible to upgrade the firmware on TS-228.. The issue must be solved in home assistant..
Same problem for me, but I use Qnap NAS: TS-253D, Firmware: 5.2.4 HA has meanwhile core-2025.5.1 but same issue with core-2025.5.0, last working core-2025.4.4
Logger: homeassistant.components.qnap.coordinator Quelle: helpers/update_coordinator.py:380 Integration: QNAP (Dokumentation, Probleme) Erstmals aufgetreten: 15:49:45 (17 Vorkommnisse) Zuletzt protokolliert: 16:07:26
Unexpected error fetching qnap data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 380, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py", line 86, in _async_update_data return await self.hass.async_add_executor_job(self._sync_update) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py", line 72, in _sync_update suppress_insecure_request_warning() if not self._verify_ssl else nullcontext() File "/usr/local/lib/python3.13/contextlib.py", line 141, in enter return next(self.gen) File "/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py", line 40, in suppress_insecure_request_warning with urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning): ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object does not support the context manager protocol
Same here
@NordFreak & @patxo, the fix I found will only work for instances running on Docker containers. It's been a while since I used HAOS (core), and I forgot that the core files cannot be modified.
Here too ! Same problem :
Échec de la configuration, nouvel essai: 'NoneType' object does not support the context manager protocol
If you have "Terminal" installed as an add-on on HAOS, go there and run "docker exec -it homeassistant bash" which will take you into Docker and from there you can change directory to the path /usr/src/homeassistant/homeassistant/components/qnap/ From there you can edit the .py file. I tried it and it worked. Note that the original line "with urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning):" also has a ":" at the end while the new one is just "urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)". I forgot to remove ":" at first and it didn't work.
Note: You need to use the "Advanced SSH and Web Terminal" for the docker command to work! See @mainmind83 comment: https://github.com/home-assistant/core/issues/144536#issuecomment-2873266051
@bravotangoau Thanks, steps to fix it with HAOS worked fine for me.
能把刷新时间开出来自己设置就好了,这样想要实时数据的可以将刷新时间设小点,不需要的就默认时间
@bravotangoau and @tascrafts Thanks, I was able to use on my HAOS as well.
Here is my details and steps:
- HA Core: 2025.5.1
- QTS version is 4.2.6 build 20240618
- NAS: TS-410
- NAS connection settings: disable enforce SSL (not secure, but hopefully this issue will be fix for SSL as well soon)
Login via SSH or Terminal add-on, than execute bash in docker, than change the directory and edit the coordinator file:
% ssh ha
➜ ~ docker exec -it homeassistant bash
homeassistant:/config# cd /usr/src/homeassistant/homeassistant/components/qnap/
homeassistant:/usr/src/homeassistant/homeassistant/components/qnap# vi coordinator.py
Original code in coordinator.py:
@contextmanager
def suppress_insecure_request_warning():
with urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning):
yield
Modified code (start on line 40):
@contextmanager
def suppress_insecure_request_warning():
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
try:
yield
finally:
pass
The last few steps after code modification:
- re-add my NAS into the integration (with admin user, with 443 https port, without verifying ssl - if it's self-signed)
- restart HA
It is a temporary solution until someone fix it in the HA integration... If you update HA Core, you have to modify this code again.
NOTE: I have reviewed with SSL related setting and it works.
Worked for me too. Just to state what will be obvious to many but not me, if you update homeassistant you will lose this change so don't do what I did and update HA immediately after making the edit to the python file 🙄
传感器的更新时间是那个?,我也去改改,默认的太慢
@zollak In your first version of reply you mentioned using the admin account to login. in the scheme of things, the info obtained in this integration are not that top secret so rather than worrying about SSL connections, I’d just create a very limited access user which has no access to any app, directory etc and use this user to login for this integration. This way, even if the password is compromised via a non-SSL connections, your account is still safe.
This solution doesn't work for me on HAOS. From the "Terminal" add-on, the command "docker exec -it homeassistant bash" returns "bash: docker: command not found."
This solution doesn't work for me on HAOS. From the "Terminal" add-on, the command "docker exec -it homeassistant bash" returns "bash: docker: command not found."
use https://github.com/hassio-addons/addon-ssh
https://github.com/home-assistant/core/issues/144536#issuecomment-2871209898
Sorry, my mistake. I was using the regular terminal instead of the advanced one. Everything works correctly now. Thanks.
Please help! I don't have qnap directory under the components, thx
@csababalogh Have you tried @zollak 's detailed instructions: https://github.com/home-assistant/core/issues/144536#issuecomment-2869675049
If you configured Qnap in configuration.yaml then you might as well delete it and install again using Devices and Services -> Add integration. then follow @zollak instructions.
@csababalogh Have you tried @zollak 's detailed instructions: #144536 (comment)
If you configured Qnap in configuration.yaml then you might as well delete it and install again using Devices and Services -> Add integration. then follow @zollak instructions.
Thanks, but I don't have docker on the HAOS.
@csababalogh Have you tried @zollak 's detailed instructions: #144536 (comment) If you configured Qnap in configuration.yaml then you might as well delete it and install again using Devices and Services -> Add integration. then follow @zollak instructions.
Thanks, but I don't have docker on the HAOS.
...and under the /homeassistant directory I don't have components:
The /usr/src is empty.
go the add-on store and look for "Advanced SSH & Web Terminal" and install it.
See @mainmind83 comment above: https://github.com/home-assistant/core/issues/144536#issuecomment-2873266051
@csababalogh after you install the "Advanced SSH & Web Terminal", you should disable the Protection mode on the addon configuration page that could provide you root access during ssh/terminal session that is required to use docker command.