API call equivalent to zmpkg.pl status ? states.json bug?

Previous development branch now released as 1.36
Locked
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

API call equivalent to zmpkg.pl status ? states.json bug?

Post by tsp84 »

Is there an API call to see if zm is running or stopped like zmpkg.pl status? The only thing I saw in docs was to use server.json but if its not a multi server setup it returns empty.

For the states.json bug. If you set the run state to STOP and run zmpkg.pl status it returns stopped, as expected. If you query the API states.json it returns that the previously active run state is still active instead of all of them = 0. ???

Code: Select all

03/24/21 18:47:23.158318 zmpkg[19552].INF [main:319] [Sanity checking States table...]
03/24/21 18:47:23.166702 zmpkg[19552].INF [main:95] [Command: status]
stopped
API returns

Code: Select all

STATES response = {'states': [{'State': {'Id': '1', 'Name': 'default', 'Definition': '', 'IsActive': '0'}}, {'State': {'Id': '8', 'Name': 'Day', 'Definition': '1:Mocord:1,2:Nodect:1,3:Modect:1,4:Modect:1,5:None:1,6:None:1,7:None:1', 'IsActive': '1'}}, {'State': {'Id': '10', 'Name': 'Night', 'Definition': '1:None:1,2:Nodect:1,3:None:1,4:None:1,5:Modect:1,6:Modect:1,7:None:1,8:Mocord:1', 'IsActive': '0'}}]}
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: API call equivalent to zmpkg.pl status ? states.json bug?

Post by tsp84 »

ah crap found it after looking in zmNinja source. daemonCheck.json
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: API call equivalent to zmpkg.pl status ? states.json bug?

Post by tsp84 »

How about the API call to change to a custom run state? /change/ seems to be just for stop/start/restart of ZM itself.
alabamatoy
Posts: 349
Joined: Sun Jun 05, 2016 2:53 pm

Re: API call equivalent to zmpkg.pl status ? states.json bug?

Post by alabamatoy »

A cURL call to "https://servername/zm/api/states/change/" . $runstate . ".json" works for me, after all the authentication and such. The value for $runstate must match a predefined runstate name.

I dunno where/how I discovered this. I just looked through the API and it actually is not explicitly documented. An API doc shortcoming, it would seem.

HTH
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: API call equivalent to zmpkg.pl status ? states.json bug?

Post by knight-of-ni »

alabamatoy wrote: Wed Mar 31, 2021 1:49 pm A cURL call to "https://servername/zm/api/states/change/" . $runstate . ".json" works for me, after all the authentication and such. The value for $runstate must match a predefined runstate name.

I dunno where/how I discovered this. I just looked through the API and it actually is not explicitly documented. An API doc shortcoming, it would seem.

HTH
Please submit a pull request to fix documentation issues. Documentation is something that requires no special programming skills. Anyone can and should help us out in this manner.

This is going to become a big issue after our next release. The UI has been significantly changed, which is going to require many documentation updates and new screenshots.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
Locked