Trigger timed alarm via API, Check State via API??

Forum for questions and support relating to the 1.29.x releases only.
Locked
pack3tl0ss
Posts: 3
Joined: Fri Apr 01, 2016 3:48 am

Trigger timed alarm via API, Check State via API??

Post by pack3tl0ss »

The new API is a great addition to ZM. Had a couple of questions, I'm pretty sure I know the answer to (I did use Google first) so the question is more about are these things planned for future development, and if by off chance it exists today...

It doesn't look like the new API yet has the capability to put a monitor in alarm state. I currently use zmtrigger.pl, and my garage door controller tells zm to put both the driveway and garage cameras in an alarm state 5 seconds after the garage door is opened and stay in alarm for 20sec. zmtrigger works, but it crashes after it's used so I run a cron job to monitor for the process and restart it after it's used and subsequently crashes. I'm not worried about fixing that, the cron job isn't graceful but gets the job done. More interested in if the new API will eventually take over this function??

The other bit is checking the current run state of zm. I have another cron job that kicks off a script which checks my wireless system to determine if either of the adults in the house are home (it checks to see if our phones are connected to WLAN). If either of us are connected it changes the state of zm. If we are home it goes into a state which has the inside camera in monitor, if we are both out then the script will put zm in a state which has the inside camera set to modect. Otherwise if we are home I disable motion detection on the inside camera. I'll also be adding a function to my garage door controller that will allow me to put the garage camera in monitor mode from my garage door controllers interface (so I'm not capturing myself tinkering in the garage).

I know there is an API to change the function of the individual monitor, which would do the trick, but it currently has the issue with a cake error viewtopic.php?f=34&t=24306&start=15 So I'm still using run states via script right now.

So here is the list of things I'm doing - curious if there is/will be API support:
  1. Trigger alarms from external system
  • determine current Run State of zm (currently querying db directly)
  • Change Run State of zm
2&3 are less of an issue, it sounds like if I upgrade CakePHP, I'll be able to use the API to query/change the function of a monitor. So I can do that vs. changing state, but interested to know if the API will be expanded for some of this stuff? Mainly interested in #1.

Great job on the new web-site btw, excited to see the project evolve.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Trigger timed alarm via API, Check State via API??

Post by asker »

pack3tl0ss wrote: It doesn't look like the new API yet has the capability to put a monitor in alarm state.
So here is the list of things I'm doing - curious if there is/will be API support:
  1. Trigger alarms from external system
  • determine current Run State of zm (currently querying db directly)
  • Change Run State of zm
2&3 are less of an issue, it sounds like if I upgrade CakePHP, I'll be able to use the API to query/change the function of a monitor. So I can do that vs. changing state, but interested to know if the API will be expanded for some of this stuff? Mainly interested in #1.

Great job on the new web-site btw, excited to see the project evolve.
a) Trigger for alarms: does not exist, would be useful to add.
b) current run state: already exists /api/States.json
c) change run state: already exists - POST with /api/states/change/<statename>.json

Finally the cake issue with PHP7 has been resolved. Steve G. upgraded the cake lib to 2.8 which is compatible with PHP7
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
pack3tl0ss
Posts: 3
Joined: Fri Apr 01, 2016 3:48 am

Re: Trigger timed alarm via API, Check State via API??

Post by pack3tl0ss »

Perfect, Thanks asker. I had read the API docs on the states, but the detail there are very brief. It looked as if I could only start/stop/restart zoneminder, it doesn't mention changing run-states. I'll play with it and submit changes with more detail around it to the API doc. Appreciate the pointer in the right direction.

I'll look into pulling zm off of Git, I have 1.29, from the iConner Master Snapshot PPA, I'm guessing I'd have to switch to git to get these changes quicker.

API Trigger to replace zmtrigger.pl would be ideal for sure.

Thanks again for the response.
Locked