Improve error logging on invalid MQTT entity state (#118006)

* Improve error logging on invalid MQTT entity state

* Explain not hanlding TpeError and ValueError

* Move length check closer to source

* use _LOGGER.exception
This commit is contained in:
Jan Bouwhuis 2024-05-24 13:11:52 +02:00 committed by GitHub
parent 7d44321f0f
commit f12aee28a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 106 additions and 12 deletions

View file

@ -373,14 +373,14 @@ class EntityTopicState:
def process_write_state_requests(self, msg: MQTTMessage) -> None:
"""Process the write state requests."""
while self.subscribe_calls:
_, entity = self.subscribe_calls.popitem()
entity_id, entity = self.subscribe_calls.popitem()
try:
entity.async_write_ha_state()
except Exception:
_LOGGER.exception(
"Exception raised when updating state of %s, topic: "
"Exception raised while updating state of %s, topic: "
"'%s' with payload: %s",
entity.entity_id,
entity_id,
msg.topic,
msg.payload,
)