Python to read MQTT messages
Posted: Monday 07 March 2022 5:32
I have an MQTT broker setup and I have setup and "MQTT Client Gateway with LAN interface" setup to listen to topics from an MQTT device (frigate). I am seeing the MQTT messages in the log as:
2022-03-05 00:25:05.876 MQTT: Topic: frigate/events, Message: {"before": {"id": "1646468697.36655-yw8znn", "camera": "backdoor", "frame_time": 1646468699.373544, "snapshot_time": 1646468698.94389, "label": "person", "top_score": 0.76953125, "false_positive": false, "start_time": 1646468697.36655, "end_time": null, "score": 0.53515625, "box": [433, 568, 556, 872], "area": 37392, "region": [64, 88, 872, 896], "stationary": false, "motionless_count": 0, "position_changes": 1, "current_zones": [], "entered_zones": [], "has_clip": true, "has_snapshot": true}, "after": {"id": "1646468697.36655-yw8znn", "camera": "backdoor", "frame_time": 1646468699.373544, "snapshot_time": 1646468698.94389, "label": "person", "top_score": 0.76953125, "false_positive": false, "start_time": 1646468697.36655, "end_time": 1646468704.540655, "score": 0.53515625, "box": [433, 568, 556, 872], "area": 37392, "region": [64, 88, 872, 896], "stationary": false, "motionless_count": 0, "position_changes": 1, "current_zones": [], "entered_zones": [], "has_clip": true, "has_snapshot": true}, "type": "end"}
This message is obviouly a json structure. I want to be able to write a python script, or plugin if necessary that can gather that data and process it. I am trying to glue a frigate (AI camera NVR) to domoticz to do some alerts and stuff. btw, frigate is really cool.
I know about node red, but did not want to install another piece of glue if the data is already coming into domotiz. I am not trying to tie this to a domoticz device, just get the data into a script
any ideas?
2022-03-05 00:25:05.876 MQTT: Topic: frigate/events, Message: {"before": {"id": "1646468697.36655-yw8znn", "camera": "backdoor", "frame_time": 1646468699.373544, "snapshot_time": 1646468698.94389, "label": "person", "top_score": 0.76953125, "false_positive": false, "start_time": 1646468697.36655, "end_time": null, "score": 0.53515625, "box": [433, 568, 556, 872], "area": 37392, "region": [64, 88, 872, 896], "stationary": false, "motionless_count": 0, "position_changes": 1, "current_zones": [], "entered_zones": [], "has_clip": true, "has_snapshot": true}, "after": {"id": "1646468697.36655-yw8znn", "camera": "backdoor", "frame_time": 1646468699.373544, "snapshot_time": 1646468698.94389, "label": "person", "top_score": 0.76953125, "false_positive": false, "start_time": 1646468697.36655, "end_time": 1646468704.540655, "score": 0.53515625, "box": [433, 568, 556, 872], "area": 37392, "region": [64, 88, 872, 896], "stationary": false, "motionless_count": 0, "position_changes": 1, "current_zones": [], "entered_zones": [], "has_clip": true, "has_snapshot": true}, "type": "end"}
This message is obviouly a json structure. I want to be able to write a python script, or plugin if necessary that can gather that data and process it. I am trying to glue a frigate (AI camera NVR) to domoticz to do some alerts and stuff. btw, frigate is really cool.
I know about node red, but did not want to install another piece of glue if the data is already coming into domotiz. I am not trying to tie this to a domoticz device, just get the data into a script
any ideas?