Change Zoneminder run states

Wouldn’t it be possible to have Openhab interact with Zoneminder to change Zoneminder RUN STATES. When an alarm arm state is set to “Away” Zoneminder run state is „Armed“ and the cameras is in motect mode And if I set a state from Openhab to “Home” the Zoneminder changed to run state „NoArmed“ and the cameras will no record (in monitor mode)?
The run states in Zoneminder is configured and I can change the states in Zoneminder server using command /usr/bin/zmpkg.pl Armed and / usr/bin/zmpkg.pl NoArmed. But Zoneminder Bindig can,t handle run states.
Does someone use something like this?

I understand this is very old but wanted to see if you ever came up with a solution?

I’m not quite sure I understand what was being requested. Was the OP asking to be able to set the Zoneminder function (i.e. Monitor, Modect, Mocord, Nodect, etc.)? If so, then the function channel can be used to do that.

Sorry for chiming in, but I think, the OP meant that you can change the general zoneminder status (= run state) via the ZM API. Here’s a link to zm’s documentation which explains the function of the run state (more details under “J”-reference in the screen shot):
https://zoneminder.readthedocs.io/en/latest/userguide/gettingstarted.html?highlight=run%20state#understanding-the-web-console
. Since it is possible to switch run states in the external app “ZMNinja”, it should be possible to do so via ZM’s API.

Just my 2 cents,
Regards,
Christian

Ah, I see. I’ve not looked into run states.

And I do see there’s an API for it, so it would be pretty easy for me to add a run-state channel on the server thing. And there’s an API to pull the list of run states, so it also would be possible to set the state/command options on that channel to include all the configured run states.

For anyone who has run states defined, I’d be curious to see the JSON returned from this API call.

http://ipaddress.of.your.zoneminder/zm/api/states.json

And hopefully the response will showa which run state is currently active.

I’ve a plain vanilla, relatively fresh, ZM installation, no individual new run states. The api call retuns:

	
states	
0	
State	
Id	"1"
Name	"default"
Definition	""
IsActive	"1"

And yes, curently “default” is the active run state in ZM. Will set up additional run states and post the results - done so, here’s the result:

	
states	
0	
State	
Id	"1"
Name	"default"
Definition	""
IsActive	"1"
1	
State	
Id	"2"
Name	"NewRunState"
Definition	"1:Monitor:1,2:Monitor:1,5:Monitor:1,6:Monitor:1"
IsActive	"0"

Nice. Thanks!

I have a version of the binding that defines a runState channel on the server/bridge thing. Note the binding is for OH 4.x.

The channel state options populate from the list of run states returned from the following ZoneMinder API call. Therefore, a Selection widget in the sitemap or in HABpanel (and I guess Main UI) will show a list of the possible state options.

http://ipaddress.of.your.zoneminder/zm/api/states.json

The state of the runState channel is set based on the active run state returned from the above query (i.e. isActive == “1”).

Sending a run state string (e.g. “default” or “NewRunState”) to the runState channel will cause the ZoneMinder server to apply that run state.

It’s working well for me. I can see where this will be a handy feature. I have a little bit of cleanup to do on the code, then I’ll submit a PR.

PR submitted.

1 Like

fast and competent reaction! Compliment! Sometimes wish paid service providers would work like this… :slight_smile: :smile:

1 Like