I’m trying to integrate Frigate with my Openhab instance.
My objective is to collect an event from MQTT, generated by Frigate, using Openhab
I’ve configured a MQTT Generic thing, and added on the channel an item, with a JSONPath profile.
The JSONPath erxpression is:
$.[?(@.type == "new")].after["id", "start_time", "label", "camera", "top_score"]
The raw message is:
{
"before": {
"id": "1647960940.191181-xzknx5",
"camera": "entrance",
"frame_time": 1647964731.740204,
"snapshot_time": 1647964730.993641,
"label": "person",
"top_score": 0.76953125,
"false_positive": false,
"start_time": 1647960940.191181,
"end_time": null,
"score": 0.76953125,
"box": [
664,
484,
725,
629
],
"area": 8845,
"region": [
360,
303,
776,
719
],
"stationary": false,
"motionless_count": 0,
"position_changes": 2,
"current_zones": [
"path"
],
"entered_zones": [
"path"
],
"has_clip": true,
"has_snapshot": true
},
"after": {
"id": "1647960940.191181-xzknx5",
"camera": "entrance",
"frame_time": 1647964732.155704,
"snapshot_time": 1647964730.993641,
"label": "person",
"top_score": 0.76953125,
"false_positive": false,
"start_time": 1647960940.191181,
"end_time": 1647964737.264736,
"score": 0.6953125,
"box": [
693,
521,
729,
629
],
"area": 3888,
"region": [
548,
400,
868,
720
],
"stationary": false,
"motionless_count": 1,
"position_changes": 2,
"current_zones": [
"path"
],
"entered_zones": [
"path"
],
"has_clip": true,
"has_snapshot": true
},
"type": "new"
}
The output, read from the item state, is not a valid JSON:
{id=1647960940.191181-xzknx5, start_time=1.647960940191181E9, label=person, camera=entrance, top_score=0.76953125}
So, I’m unable to parse it in my rule (using transform() method with JSONPath can’t work as this is not a valid fragment.
I know I can use the entire message in my rule (and in fact, this is what I’ve done), but it’s not the way I’d like to implement my rule. I’d like my item to only receive the relevant parts from the event, not the whole message.
Should I try another approach or is there a bug hidden here?