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

Unexpected error for call_service at pos 1: 'NoneType' object has no attribute 'bus' #258

Open
rofo69 opened this issue Aug 15, 2024 · 9 comments

Comments

@rofo69
Copy link

rofo69 commented Aug 15, 2024

I'm getting the following in the logs when calling zha_toolkit.zha_devices:-

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, 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(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 2763, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 817, in toolkit_service
    u.get_hass(zha_gw).bus.fire(params[p.EVT_DONE], event_data)
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'bus'

Currently running v1.1.19

And also now:-

Exception ''ZHAGatewayProxy' object has no attribute 'devices'' for service call with data '{'zha_toolkit_version': 'v1.1.19', 'zigpy_version': '0.65.3', 'zigpy_rf_version': '0.40.3', 'ieee_org': None, 'ieee': 'None', 'command': 'zha_devices', 'command_data': None, 'start_time': '2024-08-15T07:48:36.700538+00:00', 'errors': ['AttributeError("\'ZHAGatewayProxy\' object has no attribute \'devices\'")'], 'params': {'dir': 0, 'tries': 1, 'expect_reply': True, 'args': [], 'read_before_write': True, 'read_after_write': True}, 'success': False}'

@mdeweerd
Copy link
Owner

mdeweerd commented Aug 15, 2024

Running on 2024.8.1 or older ? (2024.8.0 introduced a lot of changes in zha).

EDIT: I suppose that you are on 2024.8. It looks like there is an issue with zha_toolkit::utils::get_hass() which returns None. Which means that zha_gw is "None" or hass was not properly retrieved from zha_gw.

@rofo69
Copy link
Author

rofo69 commented Aug 15, 2024

I'm running 2024.8.1

@mdeweerd
Copy link
Owner

I've added 1.1.20 as a beta/pre-release. I should log information about the properties available from the gateway to see which one we can use.

@yuejon
Copy link

yuejon commented Aug 19, 2024

I'm getting the same error with 1.1.19 and I just tried 1.1.20 but it's now throwing a different error:

Logger: homeassistant.components.script.poll_zigbee_routers
Source: helpers/script.py:525
integration: Script (documentation, issues)
First occurred: 1:31:21 PM (2 occurrences)
Last logged: 1:31:21 PM

Poll Zigbee Routers: Mudroom Light: Error executing script. Unexpected error for call_service at pos 1: Could not get hass from <zha.application.gateway.Gateway object at 0x7f3d4b9946b0>.Attributes available {dir(gateway)}.
Poll Zigbee Routers: Error executing script. Unexpected error for if at pos 1: Could not get hass from <zha.application.gateway.Gateway object at 0x7f3d4b9946b0>.Attributes available {dir(gateway)}.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, 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(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 2763, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 809, in toolkit_service
    u.get_hass(zha_gw).bus.fire(params[p.EVT_SUCCESS], event_data)
    ^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/utils.py", line 1190, in get_hass
    raise ValueError(msg)
ValueError: Could not get hass from <zha.application.gateway.Gateway object at 0x7f3d4b9946b0>.Attributes available {dir(gateway)}.

I'm currently on 2024.8.2

@mdeweerd
Copy link
Owner

I made another pre-release which should provide more info in Attributes available {dir(gateway)}..

@yuejon
Copy link

yuejon commented Aug 19, 2024

I figured out that if I put the actual name of the attribute (i.e. last_message_rssi) instead of the attribute id (i.e. 285), it works again.

@terba
Copy link

terba commented Aug 27, 2024

I get the same error when the answer to zha_toolkit.conf_report_read arrives. v1.1.19 on 2024.8.3

@mikehosmar
Copy link

Same issue running the znp backup.

v1.1.19 on 2024.8.3

@DevSecNinja
Copy link

Same issue running the znp backup.

v1.1.19 on 2024.8.3

Same issue for me with the backup automation on 2024.9.1.

michalmo added a commit to michalmo/zha-toolkit that referenced this issue Sep 17, 2024
EiNSTeiN- pushed a commit to EiNSTeiN-/zha-toolkit that referenced this issue Oct 8, 2024
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