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

Issue with unit_of_measure #369

Open
zoic21 opened this issue Jan 29, 2025 · 2 comments
Open

Issue with unit_of_measure #369

zoic21 opened this issue Jan 29, 2025 · 2 comments

Comments

@zoic21
Copy link

zoic21 commented Jan 29, 2025

Hello,

Since last update of HA I have an error when I try to set unit_of_measure on cluster metering at any value other than 0 or 1.

Here what I try to do :

Image

And here the error log :

Enregistreur: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:245
intégration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [problèmes](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
S'est produit pour la première fois: 16:47:34 (9 occurrences)
Dernier enregistrement: 18:18:34

[140243285369920] Unexpected exception
[140242094374000] Unexpected exception
[140242015180624] Unexpected exception
[140242029996368] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2795, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2838, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1109, in _async_admin_handler
    await result
  File "/usr/src/homeassistant/homeassistant/components/zha/websocket_api.py", line 1333, in set_zigbee_cluster_attributes
    response = await zha_device.write_zigbee_attribute(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<6 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/zha/zigbee/device.py", line 878, in write_zigbee_attribute
    value = convert_zcl_value(value, attr_def.type)
  File "/usr/local/lib/python3.13/site-packages/zha/application/helpers.py", line 156, in convert_zcl_value
    field_type[value.replace(" ", "_").split(".", 1)[-1]]
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/enum.py", line 789, in __getitem__
    return cls._member_map_[name]
           ~~~~~~~~~~~~~~~~^^^^^^
KeyError: '7'

I don't understand why I go this.

Thanks in advance,

@TheJulianJES
Copy link
Contributor

Per ZCL, unit_of_measure should be read-only, but #267 might cause the KeyError now.
Since unit_of_measure is of type enum8, but not a "defined enum" with members, ZHA can't convert it to the actual Enum.member type. I think we should just return 7 in convert_zcl_value then (and not error out). That should work IIRC.

Are you using a custom Zigbee device where unit_of_measure is writeable or what are you trying to do?

@zoic21
Copy link
Author

zoic21 commented Jan 29, 2025

Hello,

Thanks for your reply, I understand I think I have only device in the world with writable unit_of_mesure. It's zipulse from like : https://github.com/fairecasoimeme/ZiPulses. It's device that count pulse and we can configure unit_of_measure. By default it's kWh but I need to move it to L (7).

Thanks again for your return

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

2 participants