Bluriris/Deepstack MQTT JSON

I have my Blueiris NVR all setup to work with deepstack for object detection. Blueiris then sends an MQTT message with the JSON response from deepstack to my home assistant.

Here is the JSON output that home assistant is receiving.

[
    {
        "api": "objects",
        "found": {
            "success": true,
            "predictions": [
                {
                    "confidence": 0.76804876,
                    "label": "car",
                    "y_min": 272,
                    "x_min": 655,
                    "y_max": 378,
                    "x_max": 856
                }
            ],
            "duration": 0
        }
    }
]

I am struggling to get this data into a usable format in home assistant. What I really want is to be able to access the “label” field and the “confidence” field, so that I can display a message like “Car detected in driveway. x% Confident.” Blueiris can send a “memo” (instead of full JSON) displaying a message like this, but I would like to be able to work with the JSON so I can do things like count the number of cars, and keep it more extensible.

I have tried numerous things with value templates, like below, but can’t seem to make it work.

  - platform: mqtt
    unique_id: farmvision_driveway
    name: "farmvision_driveway"
    state_topic: "farmvision/driveway"
    value_template: "{{value_json.farmvision_driveway[0].found.predicitions[0].label}}"

I’m still trying to fully grasp value templates and json attributes in home assistant. Maybe I have a conceptual misunderstanding of how this is supposed to work.

I think I got it. In case anyone else is doing something similar:

  - platform: mqtt
    unique_id: farmvision_driveway
    name: "farmvision_driveway"
    state_topic: "farmvision/driveway"
    value_template: "{{value_json[0].found.predictions[0].label}}"
    json_attributes_topic: "farmvision/driveway"
    json_attributes_template: "{{value_json[0].found.predictions[0] | tojson}}"

Now when Blueiris publishes the JSON payload to MQTT topic farmvision/driveway, I can get the accompanying attributes of the confidence level, pixel location, etc.

attributes

2 Likes

Hey; thanks for this - what kind of configuration you have for action set for the camera on Blue Iris? Specifically - whats on post/payload?

Can you please tell me what you put in the post/payload field in Blue Iris to send the json that home assistant received? I tried just &json, but that’s not working for me. I also see that you mentioned that Blueiris can send a “memo” instead of full JSON. I cannot find the Blue Iris documentation that details what goes in the Post/Payload field to give me the AI information such as what was detected (person, car,etc…). :grimacing:

Edit: Nevermind, I got it working. I had an old instance of BI interfering with mqtt communication with the new BI.