elad-bar / ha-blueiris

Integration with Blue Iris Video Security Software
179 stars 42 forks source link

Blueiris integration stack dumps in log, error parsing json #213

Open masman69 opened 1 year ago

masman69 commented 1 year ago

While debugging other issues, I recently noticed stack traces from the BlueIris integration being logged every few seconds. The camera image responds fine in HA. I don't see any motion triggers, however. I believe the root cause of this issue is that one of my cameras is sending IsMotion="true" for the memo field instead of the AI result person, car, etc. I will fix this by not sending the memo field for this specific camera. Creating an issue bc is seems like a good place to escape quotes before parsing json. Feel free to close if you don't feel this is necessary.

Current Blue Iris trigger action: { "type": "&TYPE", "trigger": "ON", "path": "&ALERT_PATH", "memo": "&MEMO", "cam": "&CAM", "name": "&NAME" }

HA Log: 2023-07-08 09:23:34.162 ERROR (MainThread) [homeassistant.util.logging] Exception in attributes_message_received when handling msg on 'BlueIris/SGmbl/Status': '{ "type": "EXTERNAL", "trigger": "ON", "path": "SGmbl.20230708_092333.0.17-0.jpg", "memo": "IsMotion="true"", "cam": "SGmbl", "name": "Side Gimbal Cam" }' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 44, in wrapper msg_callback(msg) File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 372, in attributes_message_received payload = attr_tpl(msg.payload) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 235, in async_render_with_possible_json_value self._value_template.async_render_with_possible_json_value( File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 735, in async_render_with_possible_json_value return _render_with_context(self.template, compiled, **variables).strip() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2179, in _render_with_context return template.render(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render self.environment.handle_exception() File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception raise rewrite_traceback_stack(source=source) File "<template>", line 1, in top-level template code File "/usr/local/lib/python3.11/site-packages/jinja2/filters.py", line 1688, in do_tojson return htmlsafe_json_dumps(value, dumps=dumps, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/jinja2/utils.py", line 658, in htmlsafe_json_dumps dumps(obj, **kwargs) File "/usr/local/lib/python3.11/json/__init__.py", line 238, in dumps **kw).encode(obj) ^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/encoder.py", line 200, in encode chunks = self.iterencode(o, _one_shot=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/encoder.py", line 258, in iterencode return _iterencode(o, 0) ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/encoder.py", line 180, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type LoggingUndefined is not JSON serializable