core
core copied to clipboard
Qnap Integration failing to setup
The problem
After upgrading to core-2025.5.0b0, the Qnap integration is failing to set up, showing the following error in the integration page:
Failed setup, will retry: 'NoneType' object does not support the context manager protocol
What version of Home Assistant Core has the issue?
core-2025.4.4
What was the last working version of Home Assistant Core?
core-2025.5.0b0
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Qnap
Link to integration documentation on our website
https://rc.home-assistant.io/integrations/qnap
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
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
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 problem on released version 2025.5.0. Deleting integration and re-registering did not solve the problem "Failed setup, will retry: 'NoneType' object does not support the context manager protocol"
bum up, same as @dpan
same things happening for me
I’m seeing the same thing after upgrading to 2025.05
Same here
I’m seeing the same thing after upgrading to 2025.05 this evening.
Same issue here after upgrading to 2025.5
Same here. Removing an adding back is not working.
Same issue here after upgrading to 2025.5
Same here and would really appreciate a fix @disforw, because its the only misfunction after the upgrade to 2025.5.0 💪
Same issue here after upgrading to 2025.5
For me after the upgrade to 2025.5 the Integration still works for my older QNAP-device running firmware version 4.3.6.2805, but fails for the newer one running QTS 5.2.3.3006
Same for me, I own an old QNAP with v4 firmware and a newer one with v5 firmware, both of them have issues after upgrading to 2025.5
I guess this issue was introduced in PR https://github.com/home-assistant/core/pull/141752 by @frenck.
I think urllib3.disable_warnings() is not a context manager, that's where the TypeError comes from.
Same since the last update 😥
same issue the last update 2025.5. My last avaliable QTS version is 4.2.6 build 20240618, so I could not upgrade QNAP. I have tried with/without force ssl connection, with/without ssl verification during reconnecting. It is not possible to re-add the removed QNAP device on the integration.
2025-05-08 17:01:00.242 ERROR (MainThread) [aiohttp.server] Error handling request from <my external IP>
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py", line 510, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiohttp/web_app.py", line 569, in _handle
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 86, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 41, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
return await func(self, request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 233, in post
return await super().post(request, flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
return await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 121, in post
result = await self._flow_mgr.async_configure(flow_id, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 336, in async_configure
result = await self._async_configure(flow_id, user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 383, in _async_configure
result = await self._async_handle_step(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
flow, cur_step["step_id"], user_input
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 487, in _async_handle_step
result: _FlowResultT = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/qnap/config_flow.py", line 77, in async_step_user
unique_id = stats["system"]["serial_number"]
~~~~~^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
same here
Me to, on HAOS, but I rolled back to 2025.4.
La même chose, le retour à la 2025.4 résolu le problème pour l'instant
I managed to mitigate the issue on my setup and get it running again (for now) by changing the following lines in coordinator.py.
/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. Remember to always verify your code and make backups before running it!
I just updated to 2025.5.1 and the problem persists.
啥时候能更新修复啊,太影响使用了
能把刷新时间开出来自己设置就好了,这样想要实时数据的可以将刷新时间设置小点,不需要的就默认时间
I managed to mitigate the issue on my setup and get it running again (for now) by changing the following lines in coordinator.py.
/usr/src/homeassistant/homeassistant/components/qnap/coordinator.py
@contextmanagerdef suppress_insecure_request_warning():with urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning):yieldwith
@contextmanagerdef suppress_insecure_request_warning():urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)try:yieldfinally:pass # can't re-enable warnings, but this avoids crashingI haven't tested if this works with SSL certificates. Remember to always verify your code and make backups before running it!
Thanks for this! I was able to mitigate the issue with the following details:
- It works both on HTTP and HTTPS. Tested.
- I had to restart HA to get the integration back without error. (Even-though, after the change removing and adding back the NAS into the integration the errors were still there, without HA restart.)
找不到路径
@YXWHome I have written a step-by-step guide here: https://github.com/home-assistant/core/issues/144536#issuecomment-2869675049
This also seems to fix the problem without having to ignore the Context Manager exception.
@contextmanager
def suppress_insecure_request_warning():
import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', urllib3.exceptions.InsecureRequestWarning)
yield
Good morning. Today, day 15, I have updated to Core 2025.5.2 to see if the problem in ha with Qnap had solved. It has been very discouraging to verify that it persists, that it has not been solved. I keep the backup copies in QNAP and I am not sure what the consequences can be when I make copies again or when you want to recover them. I carry what is published on this site, in all three threads, Since the problem occurred and the truth is that because of my lack of knowledge I do not know how or when it is going to solve. My vision is surely too simple: something that worked, that is changed, I suppose that by mistake, and now it seems complicated to return to its place.