zha-toolkit icon indicating copy to clipboard operation
zha-toolkit copied to clipboard

[HA 2024.9.0] Error: module 'zigpy.zcl.foundation' has no attribute 'DATA_TYPES'

Open Nerwyn opened this issue 1 year ago • 20 comments

As of Home Assistant Core 2024.9.0, the following error is thrown for the following action:

data:
  ieee: sensor.bedroom_vindstyrka_pm2_5
  endpoint: 1
  manf: 4476
  cluster: 64638
  attribute: 0
  state_id: sensor.bedroom_vindstyrka_tvoc
  allow_create: true
action: zha_toolkit.attr_read
Exception 'module 'zigpy.zcl.foundation' has no attribute 'DATA_TYPES'' for service call with data '{'zha_toolkit_version': 'v1.1.19', 'zigpy_version': '0.66.0', 'zigpy_rf_version': '0.40.5', 'ieee_org': 'sensor.bedroom_vindstyrka_pm2_5', 'ieee': '30:fb:10:ff:fe:20:7c:47', 'command': 'attr_read', 'command_data': None, 'start_time': '2024-09-04T20:25:00.223965+00:00', 'errors': ['AttributeError("module \'zigpy.zcl.foundation\' has no attribute \'DATA_TYPES\'")'], 'params': {'endpoint_id': 1, 'cluster_id': 64638, 'attr_id': 0, 'dir': 0, 'manf': 4476, 'tries': 1, 'expect_reply': True, 'args': [], 'state_id': 'sensor.bedroom_vindstyrka_tvoc', 'allow_create': True, 'read_before_write': True, 'read_after_write': True}, 'success': False}'
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 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 828, in toolkit_service
    raise handler_exception
  File "/config/custom_components/zha_toolkit/__init__.py", line 784, in toolkit_service
    handler_result = await handler(
                     ^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 894, in command_handler_default
    return await default.default(
           ^^^^^^^^^^^^^^^^^^^^^^
  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/zcl_attr.py", line 311, in attr_read
    await attr_write(*args, **kwargs)
  File "/config/custom_components/zha_toolkit/zcl_attr.py", line 385, in attr_write
    found_attr_type = f.DATA_TYPES.pytype_to_datatype_id(
                      ^^^^^^^^^^^^
AttributeError: module 'zigpy.zcl.foundation' has no attribute 'DATA_TYPES'

Nerwyn avatar Sep 04 '24 20:09 Nerwyn

Same issue here :

Update Linky data: Error executing script. Unexpected error for call_service at pos 1: module 'zigpy.zcl.foundation' has no attribute 'DATA_TYPES'

Exception 'module 'zigpy.zcl.foundation' has no attribute 'DATA_TYPES'' for service call with data '{'zha_toolkit_version': 'v1.1.19', 'zigpy_version': '0.66.0', 'zigpy_rf_version': '0.40.5', 'ieee_org': 00:15:8d:00:05:d2:9d:c3, 'ieee': '00:15:8d:00:05:d2:9d:c3', 'command': 'attr_read', 'command_data': None, 'start_time': '2024-09-04T23:13:00.154898+00:00', 'errors': ['AttributeError("module \'zigpy.zcl.foundation\' has no attribute \'DATA_TYPES\'")'], 'params': {'endpoint_id': 1, 'cluster_id': 2820, 'attr_id': 774, 'dir': 0, 'tries': 1, 'expect_reply': True, 'args': [], 'state_id': 'sensor.linky_apparent_power', 'allow_create': True, 'read_before_write': True, 'read_after_write': True}, 'success': False}'

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 755, in async_trigger
    return await self.action_script.async_run(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1795, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 557, in _handle_exception
    raise exception
  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 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 828, in toolkit_service
    raise handler_exception
  File "/config/custom_components/zha_toolkit/__init__.py", line 784, in toolkit_service
    handler_result = await handler(
                     ^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 894, in command_handler_default
    return await default.default(
           ^^^^^^^^^^^^^^^^^^^^^^
  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/zcl_attr.py", line 311, in attr_read
    await attr_write(*args, **kwargs)
  File "/config/custom_components/zha_toolkit/zcl_attr.py", line 385, in attr_write
    found_attr_type = f.DATA_TYPES.pytype_to_datatype_id(
                      ^^^^^^^^^^^^
AttributeError: module 'zigpy.zcl.foundation' has no attribute 'DATA_TYPES'

x86fr avatar Sep 04 '24 23:09 x86fr

Here is the commit in Zigpy that broke ZHA Toolkit: https://github.com/zigpy/zigpy/pull/1463/commits/8db37354f7e7cbbceb5bbec4902e872961c40a73

Not very complex to fix (f.DATA_TYPES.pytype_to_datatype_id() => f.DataType.from_python_type() should do the trick - UNTESTED), but there is potentially a big number of users impacted.

x86fr avatar Sep 04 '24 23:09 x86fr

+1. Same issue here

samuel9554 avatar Sep 05 '24 00:09 samuel9554

+1

Smandurlo avatar Sep 05 '24 04:09 Smandurlo

+1 - Same Problem

mfwalsh avatar Sep 05 '24 14:09 mfwalsh

Not that trivial finally. The way they converted DATA_TYPES to DataType requires a lot of changes in ZHA Toolkit to match the new structure of the class. 😒

x86fr avatar Sep 05 '24 18:09 x86fr

Temp fix : downgrading to 2024.8.3 (zigpy < 0.66) solve the issue.

ha core update --version 2024.8.3

x86fr avatar Sep 05 '24 20:09 x86fr

I was able to fix most errors by replacing f.DATA_TYPES.pytype_to_datatype_id() with f.DataType.from_python_type().type_id

However I can see references to DATA_TYPES in scan_device.py and utils.py so more fixes are most likely needed.

jjrytko avatar Sep 05 '24 20:09 jjrytko

Hello, does anyone know if there will be anything new in a next update? Just to know if i retrograde or if I wait a little. Thanks :)

raspberryvincent avatar Sep 08 '24 16:09 raspberryvincent

Hello, does anyone know if there will be anything new in a next update? Just to know if i retrograde or if I wait a little. Thanks :)

If you do not need Home Assistant new features, do not upgrade ! At each update there are news bugs with Zhatoolkit ! I'm using HA 2024.6.4 and all works perfect with this version.

CordoWEB avatar Sep 11 '24 16:09 CordoWEB

What I find strange..... is that it is working (for me) with 9-BETA...... beta and NOT with 9.0

trondtorsoe avatar Sep 13 '24 05:09 trondtorsoe

same issue

nikscha avatar Sep 15 '24 12:09 nikscha

+1

jetmcquack avatar Sep 16 '24 08:09 jetmcquack

Same issue here

Sraoune avatar Sep 16 '24 16:09 Sraoune

+1

maikvitesse avatar Sep 17 '24 18:09 maikvitesse

+1

Nukle0n avatar Sep 18 '24 11:09 Nukle0n

What I find strange..... is that it is working (for me) with 9-BETA...... and NOT with 9.0

Home Assistant 9.0 -BETA was probably before ZHA was bumped to 0.0.32 which in turn uses 0.66.0

https://github.com/home-assistant/core/pull/124804

https://github.com/zigpy/zha/releases/tag/0.0.32

https://github.com/zigpy/zigpy/releases/tag/0.66.0

https://github.com/zigpy/zigpy/releases

Hedda avatar Sep 18 '24 14:09 Hedda

same issue here

Camousse88 avatar Sep 19 '24 07:09 Camousse88

https://github.com/mdeweerd/zha-toolkit/pull/263 fixes it but has yet to be merged and released, you can download those 4 affected .py files and overwrite the ones on your HA install and then relaunch zha-toolkit (or reboot your HA install) and it works again.

Nukle0n avatar Sep 19 '24 13:09 Nukle0n

Thank you, with #263 it works again for me

metallmanu avatar Sep 19 '24 14:09 metallmanu

Getting the same issue here. Anything can be done to help expedite this, beside a review from @mdeweerd ?

EiNSTeiN- avatar Oct 01 '24 19:10 EiNSTeiN-

+1

brocar avatar Oct 03 '24 12:10 brocar

Also working with 2024.10.0 and 2024.10.1

metallmanu avatar Oct 03 '24 18:10 metallmanu

+1.

Rudd-O avatar Oct 05 '24 08:10 Rudd-O

Is mdeweerd OK? Can someone who knows him or has mutual friends in common contact him and do a wellness check? No activity in this repo since months.

DFINITYManu avatar Oct 07 '24 09:10 DFINITYManu

I'm very glad to hear he's okay. :-) It did not occur to me to check his contributions page. Thanks for the tip!

DFINITYManu avatar Oct 07 '24 16:10 DFINITYManu

issue still exists in HA Core update 2024.10.1

Sander1978-dev avatar Oct 08 '24 08:10 Sander1978-dev

Tested and working for 2024.10.2

papylhomme avatar Oct 12 '24 08:10 papylhomme

Its not working for me

I still got "module 'zigpy.zcl.foundation' has no attribute 'DATA_TYPES'"

Tested for 2024.10.2, zha-toolkit v1.121 and v1.1.19

polhar avatar Oct 12 '24 17:10 polhar

Sorry for the confusion, I meant working with fixes from #263

papylhomme avatar Oct 12 '24 18:10 papylhomme