mdeweerd / zha-toolkit

🧰 Zigbee Home Assistant Toolkit - service for "rare" Zigbee operations using ZHA on Home Assistant
GNU General Public License v3.0
203 stars 33 forks source link

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

Open Nerwyn opened 2 months ago

Nerwyn commented 2 months ago

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'
x86fr commented 2 months ago

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 commented 2 months ago

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.

samuel9554 commented 2 months ago

+1. Same issue here

Smandurlo commented 2 months ago

+1

mfwalsh commented 2 months ago

+1 - Same Problem

x86fr commented 2 months ago

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 commented 2 months ago

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

ha core update --version 2024.8.3

jjrytko commented 2 months ago

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.

raspberryvincent commented 2 months ago

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 :)

CordoWEB commented 2 months ago

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.

trondtorsoe commented 2 months ago

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

nikscha commented 2 months ago

same issue

jetmcquack commented 2 months ago

+1

Sraoune commented 2 months ago

Same issue here

maikvitesse commented 2 months ago

+1

Nukle0n commented 2 months ago

+1

Hedda commented 2 months ago

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

Camousse88 commented 2 months ago

same issue here

Nukle0n commented 2 months ago

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.

metallmanu commented 2 months ago

Thank you, with #263 it works again for me

EiNSTeiN- commented 1 month ago

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

brocar commented 1 month ago

+1

metallmanu commented 1 month ago

Also working with 2024.10.0 and 2024.10.1

Rudd-O commented 1 month ago

+1.

DFINITYManu commented 1 month ago

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 commented 1 month ago

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

Sander1978-dev commented 1 month ago

issue still exists in HA Core update 2024.10.1

papylhomme commented 1 month ago

Tested and working for 2024.10.2

polhar commented 1 month ago

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

papylhomme commented 1 month ago

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

Phobos-7 commented 2 weeks ago

+1 it affects many of my devices for months now.

metallmanu commented 2 weeks ago

+1 it affects many of my devices for months now.

Just use the changed files of #263