A binary sensor has the option to select which json value to look for:
binary_sensor:
- platform: mqtt
name: "mqtt bi cam_garage person"
state_topic: "BlueIris/cam_garage/PersonDetected"
value_template: "{{ value_json.state }}" <--------- check the "state" value
payload_on: "ON"
payload_off: "OFF"
device_class: motion
I need something similar for the MQTT camera, to extract the âimageâ value.
Right now, I still just want to show the item, later I will use the image in a notification sent to my phone.
The MQTT camera doesnât seem to have a value_template option.
Iâve tried using json_attributes_topic and json_attributes_template, to no avail:
To extract the base64 string from itâs JSON expression {"val":"/9j/2wCEABALDA4MChAODQ4SE..."}. But this leads to an Error message:
Configuration invalid!: Invalid config for [mqtt]: [value_template] is an invalid option for [mqtt]. Check: mqtt->mqtt->camera->0->value_template. (See /config/configuration.yaml, line 21).
Or is there a way to solve this with the json_attributes_template ?
OK, found something, but not much. I couldnât make the MQTT camera work, but I found another way to connect the Instar camera to HA on the Instar wiki. Of course, this doesnât really work as expected. There are some caveats, some more serious than others.
The generic camera cannot be set up using YAML, only the UI.
The configuration written there doesnât work for my camera model. I could set up the RTSP stream but not the still image.
And the real problem: when I open the camera stream in HA, I can occasionally get an image, but continuous streaming does not work. Playing the RTSP stream using Mplayer from my desktop works, so the problem is on HAâs side, not the cameraâs.
OK, I found out whatâs the problem with the RTSP stream. My HA server has a Celeron CPU, which is just not powerful enough to play a 2K stream, while my desktop i7 plays it fine. If I use the 720p stream, it works fine.
So after all, the Instar camera can be made to work with HA, but not through MQTT, and it takes a lot of digging in the documentation to figure out how. In a way I donât mind it, because HTTP and RTSP are probably more efficient in transferring images and videos than MQTT anyway.
This thread is a bit old but it was the best hit when I was looking into my issue (but didnât have an answer): I want to provide metadata along with the image from Blue Iris to Home Assistant for a MQTT camera.
By digging into threads on âjson_attributes_templateâ I was able to find the answer and I wanted to post the complete solution here as someone else may need it in the future.
Here are the two Blue Iris actions that I have triggered by an alert:
Here is the full text of my current âattributesâ payload. Note that &JSON does NOT need to be surrounded by quotation marks because itâs already valid JSON. The other macros need quotes.
Then in my Home Assistant configuration I define an MQTT camera. The json_attributes_template is configured to parse the JSON Iâm sending from Blue Iris. Note that the suffix in templateâs âvalue_json.data.[attribute_name]â is just an arbitrary attribute name that I want to be populated under the MQTT camera device in Home Assistant.
Thanks for posting this solution. Is this still working for you?
The image part works great from blueiris to HA via mqtt, but for the life of me, canât get the JSON attributes working. Iâm on Feb 2024 version of Home Assistant.