New ZoneMinder API

I finally read through the whole thing. You guys are all brilliant, and I’m still stuck.

I’m trying to figure out how to fire an automation based on a specific monitor detecting a person. ZM+ES+MLAPI sends me the following over MQTT:

{"state":"alarm","detection":{"boxes":[[294,39,334,137],[430,115,706,405]],"frame_id":"37","image_dimensions":{"resized":[448,800],"original":[448,800]},"labels":["person","car"],"confidences":[0.99095618724823,0.768244922161102]},"eventid":"144321","monitor":"26","hookvalue":"0","name":"Carport 180 (Substream):(144321) [x] detected:person:99% car:77% Motion","eventtype":"event_start"}

Presumably, I’m trying to create a value.json condition that looks for “person” after “labels”: or after detected: but car and person aren’t always in the same order.

Can anyone help me figure out how to look through the entire MQTT message for “person” and fire the automation if it is, and not if it isn’t?

{{ "person" in value_json.detection.labels }} will be true if the word person is in the labels entry.

Also formatting your JSON helps to visualize it as well:

{
	"state": "alarm",
	"detection": {
		"boxes": [
			[294, 39, 334, 137],
			[430, 115, 706, 405]
		],
		"frame_id": "37",
		"image_dimensions": {
			"resized": [448, 800],
			"original": [448, 800]
		},
		"labels": ["person", "car"],
		"confidences": [0.99095618724823, 0.768244922161102]
	},
	"eventid": "144321",
	"monitor": "26",
	"hookvalue": "0",
	"name": "Carport 180 (Substream):(144321) [x] detected:person:99% car:77% Motion",
	"eventtype": "event_start"
}
1 Like

Thank you so much for this!

1 Like