zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Moes BHT-002-GCLZB "homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: State max length is 255 characters."

Open adorobis opened this issue 3 years ago β€’ 15 comments

What happened?

Since a while (not sure when exactly, but probably since one of the recent latest-dev releases my HA is flooded with the following error message for one of the devices: Moes BHT-002-GCLZB Apart from that in the logs the device and the integration seems to work ok. Full error message:

Logger: homeassistant
Source: core.py:1140
First occurred: 12:00:27 (2393 occurrences)
Last logged: 13:11:34

Error doing job: Exception in callback MQTT._mqtt_handle_message(<paho.mqtt.cl...x7f9357c36420>)
Error doing job: Exception in callback MQTT._mqtt_handle_message(<paho.mqtt.cl...x7f9357e8fa70>)
Error doing job: Exception in callback MQTT._mqtt_handle_message(<paho.mqtt.cl...x7f9357e8f6f0>)
Error doing job: Exception in callback MQTT._mqtt_handle_message(<paho.mqtt.cl...x7f9357e8c7b0>)
Error doing job: Exception in callback MQTT._mqtt_handle_message(<paho.mqtt.cl...x7f9357df8dd0>)
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 696, in _mqtt_handle_message
    self._mqtt_data.state_write_requests.process_write_state_requests()
  File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 267, in process_write_state_requests
    entity.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 556, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 673, in _async_write_ha_state
    self.hass.states.async_set(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_set
    state = State(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1140, in __init__
    raise InvalidStateError(
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: sensor.termostat_szary_program. State max length is 255 characters.

Not sure if it is z2m or ha core issue.

What did you expect to happen?

No errors in the log

How to reproduce it (minimal and precise)

Just add the Moes BHT-002-GCLZB to zigbee2mqtt and observe HA logs.

Zigbee2MQTT version

1.29.2-dev commit: e56dff4

Adapter firmware version

0x26780700

Adapter

Conbee II

Debug log

_zigbee_logs.txt

adorobis avatar Jan 17 '23 12:01 adorobis

I have also opened an issue on ha core as I'm not sure which component is causing it: https://github.com/home-assistant/core/issues/86081

adorobis avatar Jan 17 '23 12:01 adorobis

Based on the feedback from HA Core team the limit is for a long time 255 characters for entity state. I've noticed that it is now trying to publish a new entity sensor.[name]_program and it is Unknown due to this limitation. I believe it should be either removed or split into multiple entities to comply with this limits on HA side.

adorobis avatar Jan 17 '23 12:01 adorobis

Same here...

dominikfe avatar Jan 20 '23 08:01 dominikfe

There is 255 char limit for state in HA, it needs to be attribute, or to be splitted to comply with that limit...

ondrejbaranek avatar Jan 30 '23 08:01 ondrejbaranek

Same problem here AFTER updating Z2M to 1.30... No error before that....

cyberdie avatar Feb 01 '23 17:02 cyberdie

if you don't need the program as a sensor this issue can be workarounded by disabling the program sensor in HA :)

olympia avatar Feb 01 '23 17:02 olympia

Wow, cool. How come I have not figured this out :) Thanks!

adorobis avatar Feb 01 '23 18:02 adorobis

Ссли Π²Π°ΠΌ Π½Π΅ Π½ΡƒΠΆΠ½Π° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ° ΠΊΠ°ΠΊ Π΄Π°Ρ‚Ρ‡ΠΈΠΊ, Ρ‚ΠΎ эту ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΡƒ ΠΌΠΎΠΆΠ½ΠΎ ΠΎΠ±ΠΎΠΉΡ‚ΠΈ, ΠΎΡ‚ΠΊΠ»ΡŽΡ‡ΠΈΠ² ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½Ρ‹ΠΉ Π΄Π°Ρ‚Ρ‡ΠΈΠΊ Π² HA :)

it is not entirely clear how to do this, please tell me for beginners how to fix this error point by point

AlekseiPun avatar Feb 10 '23 13:02 AlekseiPun

it is not entirely clear how to do this, please tell me for beginners how to fix this error point by point

In the properties of this device in HA, find the sensor "Program" and deactivate it

Strish avatar Feb 10 '23 13:02 Strish

Π½Π΅ совсСм понятно ΠΊΠ°ΠΊ это ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ, подскаТитС поТалуйста для Π½ΠΎΠ²ΠΈΡ‡ΠΊΠΎΠ² ΠΊΠ°ΠΊ ΠΈΡΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ эту ΠΎΡˆΠΈΠ±ΠΊΡƒ ΠΏΠΎ ΠΏΡƒΠ½ΠΊΡ‚Π°ΠΌ

Π’ свойствах этого устройства Π² HA Π½Π°ΠΉΠ΄ΠΈΡ‚Π΅ Π΄Π°Ρ‚Ρ‡ΠΈΠΊ "ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ°" ΠΈ Π΄Π΅Π°ΠΊΡ‚ΠΈΠ²ΠΈΡ€ΡƒΠΉΡ‚Π΅ Π΅Π³ΠΎ

Great! Thank u)

AlekseiPun avatar Feb 10 '23 16:02 AlekseiPun

I recently installed Z2M in my HA setup (next to ZHA), the better support for the Moes BHT002 was one of the reason for this. Although I can configure the thermostat through HA climate entity, I see that the status in HA is not always in sync with the one reported by Z2M. I enabled logging and then found that very same message. Could it be the reason for the desynchronization of states ?

osmeest avatar Feb 26 '23 23:02 osmeest

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Mar 29 '23 00:03 github-actions[bot]

I recently installed Z2M in my HA setup (next to ZHA), the better support for the Moes BHT002 was one of the reason for this. Although I can configure the thermostat through HA climate entity, I see that the status in HA is not always in sync with the one reported by Z2M. I enabled logging and then found that very same message. Could it be the reason for the desynchronization of states ?

@osmeest Yes, at least for me - I'm using the instructions from @Strish as a workaround.

In the properties of this device in HA, find the sensor "Program" and deactivate it

marcusg avatar Mar 29 '23 07:03 marcusg

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Apr 30 '23 00:04 github-actions[bot]

Fixed now: https://github.com/Koenkk/zigbee2mqtt/issues/16460#issuecomment-1537341464

Koenkk avatar May 07 '23 07:05 Koenkk