Skip to content

Tuya Energy Meter - Exception in async_write_ha_state when dispatching 'tuya_entry_update...' #150293

@szilarddezso

Description

@szilarddezso

The problem

The following exception is thrown by official Tuya integration every ~10 seconds for Energy Meter Earu EAMPDW-TY-63C: Exception in _handle_state_update when dispatching 'tuya_entry_update_bfefb45bf23571af68ybma'

What version of Home Assistant Core has the issue?

core-2025.8.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tuya

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tuya/

Diagnostics information

tuya-01JF7673R82DR76HNZ8FJRQ4ZY-Edesanya Energy-1f944ded7a6e48ae127d99d8da97e659.json

Example YAML snippet

Anything in the logs that might be useful for us?

Logger: homeassistant.util.logging
Source: util/logging.py:167
First occurred: 9:56:15 AM (708 occurrences)
Last logged: 9:15:03 PM

Exception in _handle_state_update when dispatching 'tuya_entry_update_bfefb45bf23571af68ybma': (['phase_a'],) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/tuya/entity.py", line 176, in _handle_state_update self.async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1026, in async_write_ha_state self._async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1151, in _async_write_ha_state self.__async_calculate_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1088, in __async_calculate_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1032, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state value = self.native_value ^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/tuya/sensor.py", line 1534, in native_value values = ElectricityTypeData.from_raw(value) File "/usr/src/homeassistant/homeassistant/components/tuya/models.py", line 119, in from_raw voltage = struct.unpack(">H", raw[0:2])[0] / 10.0 ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ struct.error: unpack requires a buffer of 2 bytes
Exception in _handle_state_update when dispatching 'tuya_entry_update_bfefb45bf23571af68ybma': (['alarm_set_1'],) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/tuya/entity.py", line 176, in _handle_state_update self.async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1026, in async_write_ha_state self._async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1151, in _async_write_ha_state self.__async_calculate_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1088, in __async_calculate_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1032, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state value = self.native_value ^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/tuya/sensor.py", line 1534, in native_value values = ElectricityTypeData.from_raw(value) File "/usr/src/homeassistant/homeassistant/components/tuya/models.py", line 119, in from_raw voltage = struct.unpack(">H", raw[0:2])[0] / 10.0 ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ struct.error: unpack requires a buffer of 2 bytes
Exception in _handle_state_update when dispatching 'tuya_entry_update_bfefb45bf23571af68ybma': (['alarm_set_2'],) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/tuya/entity.py", line 176, in _handle_state_update self.async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1026, in async_write_ha_state self._async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1151, in _async_write_ha_state self.__async_calculate_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1088, in __async_calculate_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1032, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state value = self.native_value ^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/tuya/sensor.py", line 1534, in native_value values = ElectricityTypeData.from_raw(value) File "/usr/src/homeassistant/homeassistant/components/tuya/models.py", line 119, in from_raw voltage = struct.unpack(">H", raw[0:2])[0] / 10.0 ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ struct.error: unpack requires a buffer of 2 bytes
Exception in _handle_state_update when dispatching 'tuya_entry_update_bfefb45bf23571af68ybma': (['leakage_current'],) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/tuya/entity.py", line 176, in _handle_state_update self.async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1026, in async_write_ha_state self._async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1151, in _async_write_ha_state self.__async_calculate_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1088, in __async_calculate_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1032, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state value = self.native_value ^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/tuya/sensor.py", line 1534, in native_value values = ElectricityTypeData.from_raw(value) File "/usr/src/homeassistant/homeassistant/components/tuya/models.py", line 119, in from_raw voltage = struct.unpack(">H", raw[0:2])[0] / 10.0 ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ struct.error: unpack requires a buffer of 2 bytes
Exception in _handle_state_update when dispatching 'tuya_entry_update_bfefb45bf23571af68ybma': (['total_forward_energy'],) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/tuya/entity.py", line 176, in _handle_state_update self.async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1026, in async_write_ha_state self._async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1151, in _async_write_ha_state self.__async_calculate_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1088, in __async_calculate_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1032, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state value = self.native_value ^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/tuya/sensor.py", line 1534, in native_value values = ElectricityTypeData.from_raw(value) File "/usr/src/homeassistant/homeassistant/components/tuya/models.py", line 119, in from_raw voltage = struct.unpack(">H", raw[0:2])[0] / 10.0 ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ struct.error: unpack requires a buffer of 2 bytes

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions