Zoneminder binding

Tags: #<Tag:0x00007f5c87919520> #<Tag:0x00007f5c87919368>

(Martin Eskildsen) #82

I have also noticed that it sometimes goes offline and then shortly after comes online again. Thanks for your observations, Until otherwise is proven I will considder this as a bug/“feature” in the binding. I will have to engage a debugger to see what is going on here.

I have actually been a little in doubt on what is needed to give the best support for ZoneMidner functionality. As it is now the Trigger Event channel will change to ON regardless if the event comes from OpenHAB or elsewhere (ZoneMinder it self or another integration to ZoneMinder). I wouyld appreciate some points on what you guys think would be helpfull.
I like the idea that the EventTriggergoes off regardsless of where and what is triggering. I am thinking of an Action that can be used from the Rule to query ZoneMinder for various things about the specific event. But maybe somebody has an excellent idea of how it could be done? And what is needed?

(Dan) #83

I would leave the Trigger Event channel as it is now - I like the simplicity of an item that simply reflects (and affects) the state of the alarm.

Of course it’s straightforward to use rules to distinguish between cases where ZM has itself triggered the alarm, and cases where OH has done so.

(Martin Eskildsen) #84

That is also what I think. I was thinking of a new channel Trigger Reason, The channel can have one of the following values:

  • None - No trigger
  • Signal - Signal lost from monitor (I see this in my WiFi setup)
  • Motion - Motion has triggered
  • External - External system (eg OpenHAB) has triggered event

Does the above give sense? At least I would like to distinguish between lost signal and motion.

(Martin Eskildsen) #85

This rule should do the trick:

rule "Monitor1 TriggerEvent"
    Item zmMonitor1_TriggerEvent changed
	if (zmMonitor1_TriggerEvent.state == ON) {
		logInfo("zoneminder.rules", "ZoneMinder TriggerEvent started")
	else if (zmMonitor1_TriggerEvent.state == OFF) {
		logInfo("zoneminder.rules", "ZoneMinder TriggerEvent stopped")

(MikeH) #86

I have a similar rule. But it’s not working. Does the zone function have to be in “nodect” mode for that rule to work?
Also, I noticed in regards to changing the monitor function that although I can change the zoneminder monitor function in Openhab, Openhab doesn’t reflect the new function. For example when I go into my OpenHAB sitemap and change the function for monitor 1 from modect to nodect, in Zoneminder the function changes to nodect, but in OpenHAB it stays on modect.

After rebooting both Zoneminder & OpenHAB they appear to by in sync again.
Also my rule in OpenHAB is working.

(Dan) #87

The Trigger Reason suggestion is great. Zoneminder is truly dumb in how it deals with signal loss events, so this addition is probably necessary for the trigger switch to be useful for wifi cams


(Martin Eskildsen) #88

I have looked into my code. It shouldn’t be a problem from a coding perspective, but the problem is that the value can be set to litteraly anything from the ZoneMinder API. Actually it is (right now) possible to set this from the config page. This means that I really can’t be sure what values I am looking for. At least I have to read the ZoneMinder API documentation in more details. I tend to introduce an extra enum value: Other - that can be used when the cause is unknown. I would sugegst that the possibility to set the Cause from OpenHAB is removed, and instead just set to OpenHAB. Thus it would then be possible to more safely determine the trigger reason.

(Martin Eskildsen) #89

The update is great :slight_smile:
I have found one quite odd thing while developing the trigger stuff…
The required user rights for performing a action in the ZM GUI and through the API isn’t the same. The API seems to require more user rights, and I am quite sure that my Binding doesn’t give a good / understandable error for that. I need to improve errorhandling. Until then I recommend giving Edit rights in the System section. Though it should be related to your problem (since a reboot has solved it).

(Martin Eskildsen) #90

I have looked into the possibilities of implementing a new Channel called TriggerReason on each monitor. The channel will be readonly, and it contains a strings which can be any of the following values (in bold):

  • None - Event for monitor not triggered right now.
  • Signal - Event for monitor not triggered because of signal loss
  • Motion - Event for monitor triggered because of motion detected in ZoneMinder
  • OpenHAB - Event for monitor triggered by OpenHAB.
  • Other - Event for monitor triggered by other reason (somebody hase written an unknown reason…)

I believe that should be possible, allthough I will need to move the text that can be set today from the Cause, to the Note section (which also should be more consistent of what ZoneMinder itself does).

I hope that this approach will be useable to you guys? at least you can then see if it is triggered by OpenHAB or by something else.

(Dan) #91

super useful - thanks

(Paul Muldoon) #92

I just got the binding installed and added items for my ZoneMinder server and 1 camera. All appears to be working correctly, but should the binding be showing the video as well? Or is it to include a sitemap entry similar to the above?

I would love a Montage view within OH2 if ever possible. For now I think do something similar, would need multiple sitemap entrys?

(Martin Eskildsen) #93

I haven’t implemented anything that shows video, the idea sounds great, but I am uncertain if OpenHAB supports this kind of Channel. I will take a closer look on that one.

Correct, that needs to be done in the Sitemap

(Martin Eskildsen) #94

According to this discussion Image url, it seems that the Image Url needs to be static, it can’t be picked up from an Item. The discussion seems to be with regards to OH1, so there might be some changes in OH2?

(Martin Eskildsen) #95

Today Kai has done an initial review of the pull request. Since work is going on Kai hasn’t reviewed most of the Java code (that would be waste of Kai’s time). On the other hand I would like to see ZoneMinder in a openHAB package :slight_smile:

My plan therefore is:

  1. Add a new channel containing Event Cause.
  2. See if the problems regarding missing update of CpuLoad and DiskUsage is easily fixed (which I think should be the case), else I will remove them for now.
  3. Do the changes requested by Kai. I see some changes in channel naming coming.
  4. Commit and freeze the source code, to let Kai do the final review.

Since Java isn’t my first language, I guess Kai will find a lot of things to be changed. Hopefully they are minor things like the initial review. But I wouldn’t be surprised if Kai finds something.

In other words, I will finsih what is going on, and then make sure ZoneMinder Binding is released.

(Dan) #96

excellent - if you could then fix the disconnect/reconnect bug at some later point then that would be splendid

(Martin Eskildsen) #97

Agreed. I will see if something obvious comes around.

(Martin Eskildsen) #98

Status right now is that I have manged to implement a text Channel that contains the cause of the Event. I have renamed a couple of the channels (according to Kai’s suggestions, and generally aligned the names). I need to go through it all again to verify my work.
I am quite sure I have found a “smoking gun” with regards to the problems with Disk usage and cpu load. I allthough have to dig into the log to understand exactly why it fails, but I know where to search.

Regarding the OFFLINE problem, here I might need some help from you. I am adding some debug logging so that I hopefully can verify the cause of this problem as well. I might need your help running the new binding with Debug logging enabled. I will give a status on that when I am ready :-).

(Martin Eskildsen) #99

I have unfortunately found that ZoneMidner seems to act a little bit different from what I thought it did.
It is all about the handling of events, especially the recording modes (Mocord and Record) shows this behaviour. I thought that a event could be translated to a recording in ZoneMinder. But not quite…
With regards to motion detection yes, but when we look at what happens when we switch to Record, we will see a short event (eg. a start and then a stop occurs), but recording continues. This means that using the event Switch in openHAB won’t give the true picture to determine if ZoneMinder is Recording or not. It tells the truth about the current state of the event, but that isn’t the same story. The only / best solution I see is to add a new readonly switch called “Recording” or something like that. ON whenever the monitor is recording and OFF when it is idle. The Event switch is kept as an indicator if the monitor has an active event.

If somebody has some points about this one, then speak up :slight_smile:

I have also been looking a bit into the disconnect problem. In my ZoneMinder setup it seems (from looking at the ZoneMinder log) that ZoneMinder has some kind of hickup at almost the same time. I am a little in doubt how I can safely determine if ZoneMidner is up and running.

(Dan) #100

thanks - can I ask what you see in the zoneminder logs during the “hiccups”?

(Martin Eskildsen) #101

I think I will withdraw that statement for now, I have looked a little bit into the code and have found a possible explanation. At least that explains why it is going off line at a quite predictable interval.