core: Logger: Exception in attributes_message_received when handling msg

The problem

I was sent here after opening an issue in Valetudo repository with the hint that it has something related with logger.

Problem showed up after updating my vacuum to latest Valetudo - with the rewritten MQTT interface. I did all the steps mentioned on said repository to clean up the Home Assistant’s sensors/configuration related to Valetudo/Vacuum.

Errors show up on every restart, and during normal work after a random amount of time. As for right now I didn’t noticed any interruptions with vacuum automations/scripts and all works normal, the only thing that is wrong - is the log spammed with errors.

What is version of Home Assistant Core has the issue?

core-2021.5.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

MQTT, Logger

Link to integration documentation on our website

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

------------------------- AFTER RESTART
2021-05-20 16:50:31 ERROR (MainThread) [homeassistant.util.logging] Exception in attributes_message_received when handling msg on 'valetudo/1_lvn_rosita_mqtt/ZoneCleaningCapability/presets': '{"1648d7a3-9156-44b3-8a15-080f84dcc2ee":{"__class":"ValetudoZonePreset","metaData":{},"name":"Kuchnia","zones":[{"__class":"ValetudoZone","metaData":{},"points":{"pA":{"x":2955,"y":2565},"pB":{"x":3300,"y":2565},"pC":{"x":3300,"y":2675},"pD":{"x":2955,"y":2675}},"iterations":1},{"__class":"ValetudoZone","metaData":{},"points":{"pA":{"x":2985,"y":2670},"pB":{"x":3150,"y":2670},"pC":{"x":3150,"y":2740},"pD":{"x":2985,"y":2740}},"iterations":1}],"id":"1648d7a3-9156-44b3-8a15-080f84dcc2ee"},"f5e505f1-a475-4026-a53c-7fc8ea633594":{"__class":"ValetudoZonePreset","metaData":{},"name":"Korytarz","zones":[{"__class":"ValetudoZone","metaData":{},"points":{"pA":{"x":3105,"y":2740},"pB":{"x":3360,"y":2740},"pC":{"x":3360,"y":2915},"pD":{"x":3105,"y":2915}},"iterations":1}],"id":"f5e505f1-a475-4026-a53c-7fc8ea633594"},"16a36953-0b03-4d3d-b1c7-710f6825ae83":{"__class":"ValetudoZonePreset","metaData":{},"name":"Taras","zones":[{"__class":"ValetudoZone","metaData":{},"points":{"pA":{"x":2485,"y":2950},"pB":{"x":2670,"y":2950},"pC":{"x":2670,"y":3100},"pD":{"x":2485,"y":3100}},"iterations":1}],"id":"16a36953-0b03-4d3d-b1c7-710f6825ae83"}}'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 32, in wrapper
    msg_callback(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 206, in attributes_message_received
    payload = attr_tpl.async_render_with_possible_json_value(payload)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 552, in async_render_with_possible_json_value
    return _render_with_context(
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1359, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1316, in to_json
    return json.dumps(value)
  File "/usr/local/lib/python3.8/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/local/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type LoggingUndefined is not JSON serializable
------------------------- AFTER RANDOM TIME
2021-05-20 16:51:53 ERROR (MainThread) [homeassistant.util.logging] Exception in attributes_message_received when handling msg on 'valetudo/1_lvn_rosita_mqtt/GoToLocationCapability/presets': '{"4b55c843-359b-4e1b-8ea7-fb231b0430cb":{"__class":"ValetudoGoToLocation","metaData":{},"name":"Kuchnia","coordinates":{"x":3198,"y":2628},"id":"4b55c843-359b-4e1b-8ea7-fb231b0430cb"}}'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 32, in wrapper
    msg_callback(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 206, in attributes_message_received
    payload = attr_tpl.async_render_with_possible_json_value(payload)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 552, in async_render_with_possible_json_value
    return _render_with_context(
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1359, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1316, in to_json
    return json.dumps(value)
  File "/usr/local/lib/python3.8/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/local/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type LoggingUndefined is not JSON serializable

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Please open a new issue if this happens again.