core: Exception running handler. KeyError: 'smartenergy_metering'. Since 2023.09.

The problem

After update to 2023.09, as of 2023.9.1, the problem persists. This error keeps appearing in the history log. At the same time, the devices continue to work.

What version of Home Assistant Core has the issue?

core-2023.9.1

What was the last working version of Home Assistant Core?

core-2023.8.4

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

ZHA

Link to integration documentation on our website

No response

Diagnostics information

config_entry-zha-103ce5ad950823d22ddf07a1be95d644.json.txt

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: bellows.ezsp
Source: /usr/local/lib/python3.11/site-packages/bellows/ezsp/__init__.py:487 
First occurred: 11:20:45 (10 occurrences) 
Last logged: 12:13:11

Exception running handler
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/zigpy/endpoint.py", line 338, in __getattr__
    return self._cluster_attr[name]
           ~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'smartenergy_metering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/bellows/ezsp/__init__.py", line 485, in handle_callback
    handler(*args)
  File "/usr/local/lib/python3.11/site-packages/bellows/zigbee/application.py", line 509, in ezsp_callback_handler
    self._handle_frame(*args)
  File "/usr/local/lib/python3.11/site-packages/bellows/zigbee/application.py", line 554, in _handle_frame
    self.packet_received(
  File "/usr/local/lib/python3.11/site-packages/zigpy/application.py", line 1010, in packet_received
    self.handle_message(
  File "/usr/local/lib/python3.11/site-packages/zigpy/application.py", line 526, in handle_message
    return sender.handle_message(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/device.py", line 367, in handle_message
    self.endpoints[src_ep].handle_message(
  File "/usr/local/lib/python3.11/site-packages/zigpy/endpoint.py", line 235, in handle_message
    handler(hdr, args, dst_addressing=dst_addressing)
  File "/usr/local/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 430, in handle_message
    self.handle_cluster_general_request(hdr, args, dst_addressing=dst_addressing)
  File "/usr/local/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 476, in handle_cluster_general_request
    self._update_attribute(attr.attrid, value)
  File "/usr/local/lib/python3.11/site-packages/zhaquirks/xiaomi/__init__.py", line 296, in _update_attribute
    self.endpoint.smartenergy_metering.update_attribute(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/endpoint.py", line 340, in __getattr__
    raise AttributeError
AttributeError

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

I confirm that the error no longer appears and all works as expected. Thanks!

zigpy/zha-device-handlers#2716 should fix this. Please download the raw file and install it as a custom quirk. Then, test if the issue is resolved and that all entities update as expected again. Also, confirm that the (new) total energy consumption entity is available.

  1. The error no longer appears!
  2. rms_voltage - did not work for a long time, it works now!
  3. Active power - It worked earlier and now works.
  4. Summation delivered - did not work before, now it works. Снимок экрана 2023-11-07 в 07 20 14

@Nedjumiiro, @alucar-d, @manuele84: This issue only caused an exception because of a Xiaomi related code change in quirks / HA 2023.09. The actual issue is that the quirk is missing the (local) MeteringCluster which also causes the “total energy consumption” sensor entity to not show.

https://github.com/zigpy/zha-device-handlers/pull/2716 should fix this. Please download the raw file and install it as a custom quirk. Then, test if the issue is resolved and that all entities update as expected again. Also, confirm that the (new) total energy consumption entity is available.

Please report back if this works. You can keep the quirk installed as long as the fix isn’t in ZHA. It should be removed by the time a new zha-quirks version is merged into HA. This will likely only happen for HA Core 2023.12.0.


@IAfanasov I’m pretty sure the GoodWe integration error you posted is something different.