Consume zoneminder mqtt for a ha sensor

Hi,

I’ve got an idea where I want to have a virtual sensor in home assistant that works like a motion sensor… ie reports clear or detected, and I can look at the history bar and see when the past detections were. I want it to only register when a person is detected on my drive.

I use zoneminder and it reports events to my mqtt server. Below is an example event, notice how it recognised a car?

{"monitor":"4","eventtype":"event_start","name":"front:(259484) [a] detected:car:53% Forced Web","state":"alarm","detection":[{"box":[628,102,1136,672],"type":"object","label":"car","confidence":"52.83%"}],"eventid":"259484","hookvalue":"0"}

The detection element can contain one or more recognised objects such as car, person, cat etc.

I’ve read up on templates and processing json in home assistant but I’m just totally lost… I can’t picture how it all strings together in my head. I know a template can process one or more instances of the “detection” element but can’t see how to tie all that in with the json functions.

FYI the above snippet was published to zoneminder/4 on my mqtt server.

Any pointers on how to do this? or examples of similar instances would be greatly appreciated.

Thanks,

Jon