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
7 changed files with 106 additions and 12 deletions

View File

@ -931,7 +931,11 @@ async def test_handle_logging_on_writing_the_entity_state(
assert state is not None
assert state.state == "initial_state"
assert "Invalid value for sensor" in caplog.text
assert "Exception raised when updating state of" in caplog.text
assert (
"Exception raised while updating "
"state of sensor.test_sensor, topic: 'test/state' "
"with payload: b'payload causing errors'" in caplog.text
)
async def test_receiving_non_utf8_message_gets_logged(