Zoneminder binding

Tags: #<Tag:0x00007f5c91dbead0> #<Tag:0x00007f5c91dbe918>

(Dan) #61

Not sure - when I type ‘java -version’ I get:

Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

But I think I have a different problem - I’m getting communication errors even using http and port 80…

(Martin Eskildsen) #62

I have same version on my Windows machine, where i tested the “patch”. Given that version it should work, so there might be something else wrong. Obvoiusly it is with the binding.

I haven’t had success in changing properties in OpenHAB, it simply just fails and stays on the old properties. Have you checked that your properties was changed or not?

Either you can delete the bridge (ZoneMinder Server) or else you can just add a extra bridge to check if that comes online.
If you delete the bridge it seems to work that you just gives your new bridge the same id (then things is just mapped to the new bridge)

(Dan) #63

Yes, the properties do misbehave - I get 500 internal errors, and the settings don’t change - so I resorted to deleting the bridge and adding a new one.

However even then, with the correct http / port 80 properties it doesn’t work, giving me this in the logs:

openConnection(): Socket Exception: Connection refused (Connection refused)

Really appreciate all your work on this


(Martin Eskildsen) #64

I am not sure if this behaviour is a OH problem or a ZoneMinder binding problem.

Can you connect to your ZoneMinder Server via a browser on port 80?
Can you connect with telnet to port 6802?
Have you enabled API in ZoneMinder? Check the readme page, I have written a few things that should be done.

Could there be some firewall or something else blocking port 80 on your zm server?

Else I think next step is a debug log…

Update: It just struck my mind: Have you changed the path for the landing page in ZoneMinder. That might also give a error 500?
Default is http://<serverIP>/zm

(Dan) #65

OK - turned out I needed to enable OPT_CONTROL in Zoneminder and then restart it. Now working! Thank you!

(Dan) #66

Yes - this is working brilliantly. Thank you again!

(Martin Eskildsen) #67

I guess you mean either OPT_USE_API or OPT_TRIGGERS?
OPT_CONTROL should not be neccessary to enable.

I will enhance the ReadMe to make this clear. When those is not enabled it gives strange errors. I will also look in the code to see if error handling might be improved here.

Glad you had success :slight_smile:

(Dan) #68

Apologies for the delayed response - I think my mistake was not restarting zoneminder after enabling OPT_TRIGGERS

Thanks again for a great binding.

(MikeH) #69

I am trying to get the Zoneminder binding to work. How do you determine the port# of zoneminder to enter into the settings . When I try port 80 from my computers browser I get this message: “Apache2 Ubuntu Default Page”. So I don’t think its that. To load zondeminder I use the IP address followed by /zm. Any help would be appreciated.

(Dan) #70

with the apt-get zoneminder install it should be:

port: 80
protocol: http
additional path: /zm
username/password - per system
telnet port: 6802

(MikeH) #71

Thanks Dan, I got it working. Could you share your OpenHab setup with zoneminder, such items, sitemap and any rules. This is what I currently have:

String BackYardIPCam "Back Yard IP Camera" {channel="zoneminder:monitor:xxxxx:monitor-2:function"}
String FrontYardIPCam "Front Yard IP Camera" {channel="zoneminder:monitor:xxxxx:monitor-1:function"}
Switch ZoneMinder "Zoneminder Status" {channel="zoneminder:server:xxxxx:is-alive"}
Number CPULoad "CPU Usage [%d]" {channel="zoneminder:server:xxxxx:cpu-load"}
Number DiskUsage "Disk Usage [%d]" {channel="zoneminder:server:xxxxx:disk-usage"}


Switch item=ZoneMinder mappings=[OFF="Off", ON="On"]
Switch item=BackYardIPCam  mappings=[Monitor="Monitor", Modect="Motion Record", Record="Record"] icon="camera"
Switch item=FrontYardIPCam mappings=[Monitor="Monitor", Modect="Motion Record", Record="Record"] icon="camera"
Text item=CPULoad 
Text item=DiskUsage

The switches all report the correct the information from Zoneminder, but I am unable to change the settings of the cameras in OpenHAB. Such as changing a camera from Monitor to Modect. Also the CPULoad and DiskUsage amounts are not showing up on the sitemap.

(Dan) #72

I too couldn’t get CPULoad or DiskUsage to work, and haven’t tried changing camera modes. I use it only to detect movement on some cameras, and activate recording on others.

My setup is as follows:

I have one camera in Modect mode watching for movement by the front/street door. Zoneminder will record all that movement. I use the binding to detect loitering, i.e. movement continuing for more than two minutes. It then alerts me.

I have another camera in Nodect mode which I trigger to start recording on certain events (e.g. an alert on the street door).

Switch zmAlive "Zoneminder alive?" <camera> (startpersist) {channel="zoneminder:server:c178e3bf:is-alive"}
Switch zmStreetTrig "StreetCam trigger" (startpersist) {channel="zoneminder:monitor:c178e3bf:monitor-2:trigger-event")
Switch zmLivingRoomTrig "LivingRoomCam trigger" (startpersist) {channel="zoneminder:monitor:c178e3bf:monitor-4:trigger-event")

Hence my rules read zmStreetTrig (movement) and write zmLivingRoomTrig (to start recording).

An example of the loitering detection rule:

Rule "Street  alarm processing"
	Item zmStreetTrig changed to ON
	var Number Cleared
	var Number i

	logInfo("CAMS", "Street cam alarm received. Will now see if active for 2 minutes")

	i = 1
	while ((i=i+1) < 8) {
	    if (zmStreetTrig.state==ON) {
	        logInfo("CAMS", "Street cam alarm still active")
	    } else {
		logInfo("CAMS", "Street cam alarm not active")

	if (Cleared==0) {
	    logInfo("CAMS", "Street cam alarm was active for all 90 seconds - triggering response")
	    // notifications etc go here

        } else {
	    logInfo("CAMS", "Street cam alarm not active for all 90 seconds - disregarding")

I have another simple rule to notify me if zmAlive goes off, because presumably my zoneminder system is down for some reason.

The sitemap then just has two switches, one showing me if there is movement on the street, another letting me manually start recording on the living room camera:

Frame label="Zoneminder" {
	Switch item=zmAlive
	Switch item=zmStreetTrig
	Switch item=zmLivingRoomTrig


(Martin Eskildsen) #73

By default diskusage count is disabled. It is because the zonemidner server uses a du xommand, more or less from the root of the drive. I read some posts, about it, and thought that polling this every 10 seconds won’t do your ZoneMinder server any good. And DiskUsage shouldn’t change from no problem to a problem in 10 seconds time… I was a bit undetermined of what would be a good interval., so I have set it to zero eg. disabled). Cpu load shouldn’t be affected by it, but there might be a bug there. I guess that might be a possibility (haven’t tested that aspect…).

Until now I have only tested the write back mechanishm (eg. to change from modect to monitor and vice versa. In the debbugger it seemed to work just fine, but in my newly installed OH2 (three days ago) it doesn’t work (actually nothing happends). This is obviously a bug, I need to dig a little bit into that one.

My config for one camera is:

Switch zmsIsAlive 			"Zoneminder Alive [%s]"			<switch>	{channel="zoneminder:server:myzoneminder:is-alive"}
Number zmsCpuLoad 			"ZoneMinder Server Load [%d]"				{channel="zoneminder:server:myzoneminder:cpu-load"}
Number zmsDiskUsage			"ZoneMinder Disk Usage [%d]"				{channel="zoneminder:server:myzoneminder:disk-usage"}
String zmsServerVersion			"ZoneMinder Server Version [%s]"			{channel="zoneminder:server:myzoneminder:zm-version"}
String zmsServerApiVersion 		"ZoneMinder Server Version [%s]"			{channel="zoneminder:server:myzoneminder:zm-api-version"}

String zmMonitor1_Name 			"Name [%s]" 						{channel="zoneminder:monitor:myzoneminder:monitor-1:name"}
Switch zmMonitor1_IsAlive 		"Alive [%s]" 				<switch>	{channel="zoneminder:monitor:myzoneminder:monitor-1:is-alive"}
Switch zmMonitor1_Enabled 		"Enabled [%s]" 				<switch>	{channel="zoneminder:monitor:myzoneminder:monitor-1:enabled"}
String zmMonitor1_SourceType 		"Source [%s]" 						{channel="zoneminder:monitor:myzoneminder:monitor-1:sourcetype"}
Switch zmMonitor1_TriggerEvent 		"Trigger [%s]"	 			<switch>	{channel="zoneminder:monitor:myzoneminder:monitor-1:trigger-event"}
String zmMonitor1_Function 		"Function [%s]" 					{channel="zoneminder:monitor:myzoneminder:monitor-1:function"}
Switch zmMonitor1_CaptureStatus 	"Capture Daemon [%s]" 			<switch>	{channel="zoneminder:monitor:myzoneminder:monitor-1:daemon-capture-state"}
String zmMonitor1_CaptureStatusText 	"Capture statustext [%s]"  				{channel="zoneminder:monitor:myzoneminder:monitor-1:daemon-capture-statustext"}
Switch zmMonitor1_AnalysisStatus 	"Analysis Daemon [%s]" 			<switch>	{channel="zoneminder:monitor:myzoneminder:monitor-1:daemon-analysis-state"}
String zmMonitor1_AnalysisStatusText 	"Analysis StatusText [%s]" 				{channel="zoneminder:monitor:myzoneminder:monitor-1:daemon-analysis-statustext"}
Switch zmMonitor1_FrameStatus		"Frame Daemon [%s]"			<switch>	{channel="zoneminder:monitor:myzoneminder:monitor-1:daemon-frame-state"}
String zmMonitor1_FrameStatusText 	"Frame StatusText [%s]"	 				{channel="zoneminder:monitor:myzoneminder:monitor-1:daemon-frame-statustext"}

My sitemap looks like this:

sitemap zoneminder label="Zoneminder"
Frame {
	Text item=zmsIsAlive label="ZoneMinder Server [%s]" {
		Frame {
			Switch item=zmsIsAlive
			Text  item=zmsCpuLoad
			Text  item=zmsDiskUsage
			Text  item=zmsServerVersion
			Text  item=zmsServerApiVersion

	Text item=zmMonitor1_Function label="Monitor-1 [%s]" {
		Frame {
			Text 	item=zmMonitor1_Name
			Switch	item=zmMonitor1_Enabled
			Text 	item=zmMonitor1_SourceType
			Switch	item=zmMonitor1_TriggerEvent
			Text 	item=zmMonitor1_Function
			Text 	item=zmMonitor1_IsAlive
			Text 	item=zmMonitor1_CaptureStatus
			Text 	item=zmMonitor1_CaptureStatusText
			Text 	item=zmMonitor1_AnalysisStatus
			Text 	item=zmMonitor1_AnalysisStatusText
			Text 	item=zmMonitor1_FrameStatus
			Text 	item=zmMonitor1_FrameStatusText

I am sorry that I haven’t answered, but I have been busy on cleaning my own OH install (I have had some problems in my production environment that I needed to take care of urgently). So all my plans of looking into Zoneminder Binding has been postponed.
I will try to prioritize the issue with setting values from OpenHAB (eg. function mode and Trigger)

EDIT (2016.12.29): Typo in items section fixed. (Swicth -> Switch)

(Martin Eskildsen) #74

I have been looking at the code, and certainly all of the parameters that could be set from OpenHAB was set properly. The Trigger failed, and “Enabled” and “Function” needs some additional coding…

The Trigger issue has been fixed,
A new jar could be found at

And by the way, thanks guys for all your testing, :slight_smile:

(Dan) #75

not at all - thank you!

(Martin Eskildsen) #76

I have now impelemented the two missing functions, so now you should be able to toggle the Enabled State from OpenHAB and also change the Function between the six allowed states: None, Monitor, Modect, Mocord, Record, Nodect.

I have just tested sporadically, and iut seems to work. I will test it more in depth, and report back. For all brave men/women, you can grab the version here:

UPDATE: ReadMe has been updated with a sample configuration.

The Text in the Readme need a general overhaul, but the Config should be close to Copy / Paste. (User credentials need to be set).

(Dan) #77

thanks - your work on this is really appreciated.

One minor point - your example rules start with “import” lines… these aren’t necessary in OH2

(Martin Eskildsen) #78

Hmmm, well spoitted. I actually copied my rules from OH1 and when I copied to the readMe I noticed the import s and remembered that I have read somewhere that at least some of them wasn’t neccessary. I then thought: Nobody will notice…

But I was obviously wrong. I will update the sample config accordingly :slight_smile:

(Dan) #79

Playing around with the binding a bit more, I’ve discovered an odd problem.

Every few minutes the “Is Alive” switch goes off for almost exactly 6.4 seconds (I have the API polling interval set to 5 seconds). I’m fairly sure it’s not a network problem as the ZM server remains accessible throughout (via web or zmNinja)

Does anyone else see this?

(MikeH) #81

Thanks for all your work on the Zoneminder binding. Changing the camera functions from within OpenHAB works great. I still can’t get the disk usage and load feature to work though.

I also noticed the “Is Alive” switch changes to off sometimes. I also notice it when I change the function on a camera.

Also, is there a way for OpenHAB to receive a notice from Zoneminder that motion was detected on a camera so that I can set up a rule to react to it?