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

v1.1.19 - zha_devices failure #269

Closed
xaf opened this issue Nov 2, 2024 · 7 comments
Closed

v1.1.19 - zha_devices failure #269

xaf opened this issue Nov 2, 2024 · 7 comments

Comments

@xaf
Copy link

xaf commented Nov 2, 2024

Hello,

zha-toolkit is failing for some simple operations in my home assistant.
I'm using:

  • zha-toolkit v1.1.19
  • home-assistant v2024.10.4

And when I run the following service call:

action: zha_toolkit.zha_devices
data:
  event_done: zha_devices

I get the following error:

Failed to perform the action zha_toolkit.zha_devices. Unknown error

With the following logs: (putting the full traceback, but only the last file is part of zha-toolkit)

homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
homeassistant  |     await func(hass, connection, msg)
homeassistant  |   File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 816, in handle_execute_script
homeassistant  |     script_result = await script_obj.async_run(
homeassistant  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1795, in async_run
homeassistant  |     return await asyncio.shield(create_eager_task(run.async_run()))
homeassistant  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in async_run
homeassistant  |     await self._async_step(log_exceptions=False)
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
homeassistant  |     self._handle_exception(
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 557, in _handle_exception
homeassistant  |     raise exception
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
homeassistant  |     await getattr(self, handler)()
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
homeassistant  |     response_data = await self._async_run_long_action(
homeassistant  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
homeassistant  |     return await long_task
homeassistant  |            ^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
homeassistant  |     response_data = await coro
homeassistant  |                     ^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
homeassistant  |     return await target(service_call)
homeassistant  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/config/custom_components/zha_toolkit/__init__.py", line 817, in toolkit_service
homeassistant  |     u.get_hass(zha_gw).bus.fire(params[p.EVT_DONE], event_data)
homeassistant  |     ^^^^^^^^^^^^^^^^^^^^^^
homeassistant  | AttributeError: 'NoneType' object has no attribute 'bus'

I've seen other threads talking about issues that could be related to versions of home assistant, but the solution was generally to go to v1.1.19... but that's already the version I have!

@pvalsecc
Copy link

pvalsecc commented Nov 9, 2024

Same here with the 1.1.21, but it gives me more details:

Could not get hass from <zha.application.gateway.Gateway object at 0x7f64dc4320>.Attributes available ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_async_device_joined', '_async_device_rejoined', '_async_initialize', '_await_and_log_pending', '_background_tasks', '_cancel_cancellable_timers', '_device_availability_checker', '_device_init_tasks', '_devices', '_emit_group_gateway_message', '_event_tasks', '_find_coordinator_device', '_global_listeners', '_groups', '_handle_event_protocol', '_listeners', '_reload_task', '_tracked_completable_tasks', '_untracked_background_tasks', 'application_controller', 'async_add_executor_job', 'async_add_zha_job', 'async_block_till_done', 'async_create_background_task', 'async_create_task', 'async_create_zigpy_group', 'async_device_initialized', 'async_fetch_updated_state_mains', 'async_from_config', 'async_initialize', 'async_initialize_devices_and_entities', 'async_remove_device', 'async_remove_zigpy_group', 'async_run_zha_job', 'async_update_device', 'config', 'connection_lost', 'coordinator_zha_device', 'create_platform_entities', 'create_task', 'device_initialized', 'device_joined', 'device_left', 'device_removed', 'devices', 'emit', 'get_application_controller_data', 'get_device', 'get_group', 'get_or_create_device', 'get_or_create_group', 'global_updater', 'group_added', 'group_member_added', 'group_member_removed', 'group_removed', 'groups', 'handle_message', 'load_devices', 'load_groups', 'loop', 'on_all_events', 'on_event', 'once', 'radio_concurrency', 'radio_type', 'raw_device_initialized', 'shutdown', 'shutting_down', 'state', 'track_task'].

I have HASS version:

Core 2024.11.1
Supervisor 2024.11.2
Operating System 13.2
Interface utilisateur 20241106.2

@MikeBP13
Copy link

Same issue here...

@Jon87
Copy link

Jon87 commented Dec 12, 2024

Same here, I'm on v1.1.19

run
zha_toolkit.zha_devices

but get this error every time;

Failed to perform the action zha_toolkit.zha_devices. Unknown error

looking into the logs I can see this error;

  File "/config/custom_components/zha_toolkit/default.py", line 51, in default
    await handler(app, listener, ieee, cmd, data, service, params, event_data)
  File "/config/custom_components/zha_toolkit/zha.py", line 48, in zha_devices
    devices = [device.zha_device_info for device in listener.devices.values()]
                                                    ^^^^^^^^^^^^^^^^
AttributeError: 'ZHAGatewayProxy' object has no attribute 'devices'

@mdeweerd
Copy link
Owner

I have merged a few PRs the last days that likely fix this.
My HA activity was very low priority the last semester, hence the delay.

If this is fixed for you, let me know, so that I can close it or try to look further.

@michaelblight
Copy link

No - I'm getting the following error on 1.1.23:

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/zha_toolkit/zha.py:48
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 13:22:38 (1 occurrences)
Last logged: 13:22:38

[140511990730320] Error handling message: Unknown error (unknown_error) Michael Blight from 192.168.0.31 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 816, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        msg.get("variables"), context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1801, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step
    self._handle_exception(
    ~~~~~~~~~~~~~~~~~~~~~~^
        ex, continue_on_error, self._log_exceptions or log_exceptions
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 833, in toolkit_service
    raise handler_exception
  File "/config/custom_components/zha_toolkit/__init__.py", line 785, in toolkit_service
    handler_result = await handler(
                     ^^^^^^^^^^^^^^
    ...<8 lines>...
    )
    ^
  File "/config/custom_components/zha_toolkit/__init__.py", line 899, in command_handler_default
    return await default.default(
           ^^^^^^^^^^^^^^^^^^^^^^
        app, listener, ieee, cmd, data, service, params, event_data
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/zha_toolkit/default.py", line 51, in default
    await handler(app, listener, ieee, cmd, data, service, params, event_data)
  File "/config/custom_components/zha_toolkit/zha.py", line 48, in zha_devices
    devices = [device.zha_device_info for device in listener.devices.values()]
                                                    ^^^^^^^^^^^^^^^^
AttributeError: 'ZHAGatewayProxy' object has no attribute 'devices'

mdeweerd added a commit that referenced this issue Dec 26, 2024
Fix #269 Adjust method to get list of devices to current ZHA code
@mdeweerd
Copy link
Owner

I reproduced the issue and it's fixed in 1.1.24

@michaelblight
Copy link

Confirmed, thanks.

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

No branches or pull requests

6 participants