MQTT Error for one of 11 identical thermostats

I have 11 Zigbee thermostats installed which are added via Zigbee2MQTT.
For one of them I get an error every 80 milliseconds in the log:

2023-02-06 21:41:32.000 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback MQTT._mqtt_handle_message(<paho.mqtt.cl...xffff800673e0>)
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 693, 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 566, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 683, in _async_write_ha_state
self.hass.states.async_set(
File "/usr/src/homeassistant/homeassistant/core.py", line 1512, in async_set
state = State(
File "/usr/src/homeassistant/homeassistant/core.py", line 1144, in __init__
raise InvalidStateError(
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: sensor.thermostat_kinderzimmer_jan_program. State max length is 255 characters.

I compared the MQTT message for this thermostat with another one, and except for the temperature value they are identical, specifically the length is the same.
So I’m not sure why it is complaining about this one.
It also seems to work just fine.

I’m not sure how long I have this error now.
I was only looking at the logs because since the 2023.2.2 update the system runs only for a couple of hours until Home Assitant gets unresponsive and I have to unplug the hardware.

HA 2023.2.2
Zigbee2MQTT 1.30.1

I have looked at the log from today again, and now I see that it is not only the one thermostat, it’s all of them who generate this error message.
Since HA does not keep many old logs I unfortunately cannot tell if this started with the update to 1.30.0 or if the error was there before. But roughly the same time as this update HA stops working after approximately 10 hours of operation.

You are not alone with this problem
I post here

https://community.home-assistant.io/t/moes-bht-002gclzb-big-probleme-since/530043

And here is an issue open

https://github.com/Koenkk/zigbee2mqtt/issues/16460

It dies again, 11 hours of runtime this time.
Here are the last minutes in the log:

2023-02-07 18:03:51.368 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback MQTT._mqtt_handle_message(<paho.mqtt.cl...xffff78fa2420>)
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 693, 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 566, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 683, in _async_write_ha_state
    self.hass.states.async_set(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1512, in async_set
    state = State(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1144, in __init__
    raise InvalidStateError(
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: sensor.thermostat_buro_program. State max length is 255 characters.
2023-02-07 18:03:55.402 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback MQTT._mqtt_handle_message(<paho.mqtt.cl...xffff79f7da10>)
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 693, 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 566, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 683, in _async_write_ha_state
    self.hass.states.async_set(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1512, in async_set
    state = State(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1144, in __init__
    raise InvalidStateError(
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: sensor.thermostat_buro_program. State max length is 255 characters.
2023-02-07 18:22:59.241 WARNING (MainThread) [homeassistant.components.binary_sensor] Updating fritz binary_sensor took longer than the scheduled update interval 0:00:30
2023-02-07 18:23:00.870 WARNING (MainThread) [homeassistant.components.switch] Updating fritz switch took longer than the scheduled update interval 0:00:30
2023-02-07 18:23:02.617 WARNING (MainThread) [homeassistant.components.sensor] Updating fritz sensor took longer than the scheduled update interval 0:00:30
2023-02-07 18:23:04.731 WARNING (MainThread) [homeassistant.helpers.entity] Update of switch.fritz_box_7590_wi_fi_osre_2_4ghz is taking over 10 seconds
2023-02-07 18:23:06.210 WARNING (MainThread) [homeassistant.helpers.entity] Update of switch.fritz_box_7590_wi_fi_osre_5ghz is taking over 10 seconds
2023-02-07 18:23:06.934 WARNING (MainThread) [homeassistant.helpers.entity] Update of switch.fritz_box_7590_wi_fi_osre_gast is taking over 10 seconds
2023-02-07 18:23:16.263 WARNING (MainThread) [homeassistant.components.sensor] Updating fritz sensor took longer than the scheduled update interval 0:00:30
2023-02-07 18:23:28.865 WARNING (Thread-2 (_thread_main)) [homeassistant.components.mqtt.client] Disconnected from MQTT server homeassistant.local:1883 (16)
2023-02-07 18:23:36.268 WARNING (Thread-2 (_thread_main)) [homeassistant.components.mqtt.client] Disconnected from MQTT server homeassistant.local:1883 (16)
2023-02-07 18:24:33.409 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_eg_bathroom (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 1.298 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:24:51.023 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_eg_kitchen (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 0.424 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:25:04.842 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_eg_dining (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 1.191 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:25:35.749 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_eg_child (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 6.078 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:26:07.213 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_eg_livingroom (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 4.412 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:26:53.752 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_ug_roomwest (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 4.271 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:27:28.994 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_ug_bedroom (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 3.887 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:27:52.477 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_ug_bathroom (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 1.963 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:28:16.680 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_ug_child (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 1.250 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:28:40.127 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for climate.temp_ug_washroom (<class 'homeassistant.components.mqtt.climate.MqttClimate'>) took 1.021 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
2023-02-07 18:30:15.711 WARNING (MainThread) [homeassistant.components.sensor] Updating fritz sensor took longer than the scheduled update interval 0:00:30
2023-02-07 18:40:05.077 WARNING (KNX Interface) [xknx.log] Received DisconnectRequest from tunnelling server.

Same problem

I think the problem is that the state topic of the sensor exccetd the 255 character limit since one of the latest updates.

{
    "child_lock": "LOCK",
    "current_heating_setpoint": 21,
    "deadzone_temperature": 1,
    "heat": "OFF",
    "last_seen": "2023-02-08T18:15:09+01:00",
    "linkquality": 180,
    "local_temperature": 21.5,
    "local_temperature_calibration": -2,
    "max_temperature": 35,
    "max_temperature_limit": 35,
    "min_temperature_limit": null,
    "preset": "hold",
    "preset_mode": "hold",
    "program": {
        "saturday_p1_hour": 6,
        "saturday_p1_minute": 0,
        "saturday_p1_temperature": 24,
        "saturday_p2_hour": 12,
        "saturday_p2_minute": 0,
        "saturday_p2_temperature": 23,
        "saturday_p3_hour": 14,
        "saturday_p3_minute": 30,
        "saturday_p3_temperature": 22,
        "saturday_p4_hour": 17,
        "saturday_p4_minute": 30,
        "saturday_p4_temperature": 21,
        "sunday_p1_hour": 6,
        "sunday_p1_minute": 0,
        "sunday_p1_temperature": 19,
        "sunday_p2_hour": 12,
        "sunday_p2_minute": 30,
        "sunday_p2_temperature": 20,
        "sunday_p3_hour": 14,
        "sunday_p3_minute": 30,
        "sunday_p3_temperature": 21,
        "sunday_p4_hour": 18,
        "sunday_p4_minute": 30,
        "sunday_p4_temperature": 20,
        "weekdays_p1_hour": 6,
        "weekdays_p1_minute": 0,
        "weekdays_p1_temperature": 20,
        "weekdays_p2_hour": 11,
        "weekdays_p2_minute": 30,
        "weekdays_p2_temperature": 21,
        "weekdays_p3_hour": 13,
        "weekdays_p3_minute": 30,
        "weekdays_p3_temperature": 22,
        "weekdays_p4_hour": 17,
        "weekdays_p4_minute": 30,
        "weekdays_p4_temperature": 23
    },
    "running_state": "idle",
    "sensor": "AL",
    "system_mode": "heat"
}

I think I can remember that the "program":part was not in the state before the 1.30.0 update for my sensor. At least not when “preset” is “hold”
If the update made this change, it has to be reversed in order to not break the HA integration I think.

I went back to Zigbee2MQTT 1.29.2 and now the error is not logged anymore.
I hope my system runs stable again.

comment do you have to do to downgrade please

Thank’s for your help