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
71.06k stars 29.72k forks source link

qbittorent integration causing errors in 2024.7.1 #121358

Open dangel666 opened 2 months ago

dangel666 commented 2 months ago

The problem

Logger: homeassistant Source: components/qbittorrent/sensor.py:181 First occurred: 07:51:47 (6 occurrences) Last logged: 07:54:17

Error doing job: Task exception was never retrieved (None) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 255, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 411, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 491, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1007, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1133, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1068, in async_calculate_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1013, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 533, in state value = self.native_value ^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/qbittorrent/sensor.py", line 170, in native_value return self.entity_description.value_fn(self.coordinator) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/qbittorrent/sensor.py", line 101, in value_fn=lambda coordinator: count_torrents_in_states(coordinator, []), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/qbittorrent/sensor.py", line 181, in count_torrents_in_states return len(torrents) ^^^^^^^^^^^^^ TypeError: object of type 'NoneType' has no len()

What version of Home Assistant Core has the issue?

core-2024.7.1

What was the last working version of Home Assistant Core?

core-2024.6.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

qbittorrent

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-07-06 07:51:17.831 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity sensor.qbittorrent_all_torrents for domain sensor with platform qbittorrent
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 912, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1362, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1007, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1133, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1068, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1013, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 533, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/qbittorrent/sensor.py", line 170, in native_value
return self.entity_description.value_fn(self.coordinator)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/qbittorrent/sensor.py", line 101, in <lambda>
value_fn=lambda coordinator: count_torrents_in_states(coordinator, []),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/qbittorrent/sensor.py", line 181, in count_torrents_in_states
return len(torrents)
^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()

Additional information

I first tried 2024.7 and reverted due to this - the sensor went missing which I thought was odd and hence I looked (better) when trying 2024.7.1 and found this in the logs on boot.

home-assistant[bot] commented 2 months ago

Hey there @geoffreylagaisse, @finder39, mind taking a look at this issue as it has been labeled with an integration (qbittorrent) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `qbittorrent` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign qbittorrent` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


qbittorrent documentation qbittorrent source (message by IssueLinks)

apedance commented 1 month ago

I have the same issues.

dangel666 commented 1 month ago

2024.7.3 still has the same problems.

YoYoost commented 1 month ago

Maybe this is fixed by https://github.com/home-assistant/core/pull/122848?

tophattwaffle commented 1 week ago

Still broken in 2024.8.3. I attempted to remove and re-add the qbit integration and HA throws an error when clicking "Delete".

ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 1007, in async_get_component comp = await self.hass.async_add_import_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, *self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1067, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func return func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/usr/src/homeassistant/homeassistant/components/qbittorrent/init.py", line 30, in from .coordinator import QBittorrentDataCoordinator File "/usr/src/homeassistant/homeassistant/components/qbittorrent/coordinator.py", line 16, in from qbittorrentapi.torrents import TorrentStatusesT ImportError: cannot import name 'TorrentStatusesT' from 'qbittorrentapi.torrents' (/usr/local/lib/python3.12/site-packages/qbittorrentapi/torrents.py). Did you mean: 'TorrentStates'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 462, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 537, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, 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 210, 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 85, 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 32, 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/config/config_entries.py", line 95, in delete result = await hass.config_entries.async_remove(entry_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1762, in async_remove await entry.async_remove(self.hass) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 868, in async_remove component = await integration.async_get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1027, in async_get_component self._component_future.result() File "/usr/src/homeassistant/homeassistant/loader.py", line 1019, in async_get_component comp = self._get_component() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1067, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func return func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/usr/src/homeassistant/homeassistant/components/qbittorrent/init.py", line 30, in from .coordinator import QBittorrentDataCoordinator File "/usr/src/homeassistant/homeassistant/components/qbittorrent/coordinator.py", line 16, in from qbittorrentapi.torrents import TorrentStatusesT ImportError: cannot import name 'TorrentStatusesT' from 'qbittorrentapi.torrents' (/usr/local/lib/python3.12/site-packages/qbittorrentapi/torrents.py). Did you mean: 'TorrentStates'?