create a code that change the "Running State"?

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

create a code that change the "Running State"?

Post by david1234 »

Hello ,
wanted to know if I can connect to the server and send him change state (diable - running \ running-diable) using pythone\nodejs or something ?
can I do something like this ?
using PI
I want to make a on\off switch to the zonminder .

can I do this ?

I found this

Code: Select all

https://pyzm.readthedocs.io/en/latest/
can this help me ?
didn't see how to change state there
Thanks ,
User avatar
burger
Posts: 390
Joined: Mon May 11, 2020 4:32 pm

Re: create a code that change the "Running State"?

Post by burger »

This can be done w/API.

https://zoneminder.readthedocs.io/en/stable/api.html

ctrl-f run state
fastest way to test streams:
ffmpeg -i rtsp://<user>:<pass>@<ipaddress>:554/path ./output.mp4 (if terminal only)
ffplay rtsp://<user>:<pass>@<ipaddress>:554/path (gui)
find paths on ispydb or in zm hcl

If you are new to security software, read:
https://wiki.zoneminder.com/Dummies_Guide
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: create a code that change the "Running State"?

Post by david1234 »

something isn't wroking
I did everythin it said in the manual.
but I can't enter using the API
I get this message

Code: Select all

curl -XPOST -d "user=David&pass=DavidPass" http://10.0.0.105/zm/api/login.json
{"name":"Not Found","message":"Not Found","url":"\/api\/zm\/api\/host\/login.json"
I'm using the zonminder on Raspberry pi 3B+

this is what I have on the api library -

Code: Select all

pi@raspberrypi:~$ ls -ls /usr/share/zoneminder/www/api/
total 40
 4 drwxr-xr-x 10 root root  4096 Jun 18 13:38 app
 4 -rw-r--r--  1 root root   174 Jun  6 18:07 build.properties
12 -rw-r--r--  1 root root 10315 Jun  6 18:07 build.xml
 4 -rw-r--r--  1 root root   837 Jun  6 18:07 composer.json
 4 -rw-r--r--  1 root root  3252 Jun  6 18:07 CONTRIBUTING.md
 4 -rw-r--r--  1 root root  1454 Jun  6 18:07 index.php
 4 drwxr-xr-x  3 root root  4096 Apr 30 00:41 lib
 4 -rw-r--r--  1 root root   437 Jun  6 18:07 README.md
what is missing ?

Thanks,
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: create a code that change the "Running State"?

Post by david1234 »

anyone?
User avatar
burger
Posts: 390
Joined: Mon May 11, 2020 4:32 pm

Re: create a code that change the "Running State"?

Post by burger »

Did you enable the API?

Test the API without auth, first.

That file listing is correct. You aren't missing any files there.
fastest way to test streams:
ffmpeg -i rtsp://<user>:<pass>@<ipaddress>:554/path ./output.mp4 (if terminal only)
ffplay rtsp://<user>:<pass>@<ipaddress>:554/path (gui)
find paths on ispydb or in zm hcl

If you are new to security software, read:
https://wiki.zoneminder.com/Dummies_Guide
bbunge
Posts: 2934
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: create a code that change the "Running State"?

Post by bbunge »

Easy to change the run state with a cron job

#set different runstate for weekends
00 1 * * 6 www-data /usr/bin/zmpkg.pl Weekend
00 23 * * 7 www-data /usr/bin/zmpkg.pl Weekday

I had a server that was set to run some cams in mocord on working hours and modect on nights and weekends. You can also run the command from a command prompt

https://wiki.zoneminder.com/Cron
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: create a code that change the "Running State"?

Post by david1234 »

the api is open
and also
I disable the auth
restart the zonminder
same resualt

maybe I'm missing setting somewhere?



get empty resualt

bbunge
you have a very good idea , but I want to control it without knowning when I want to change the state .
if it was every day at 8 am , then it's good idea - but this is not my case


Thanks ,
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: create a code that change the "Running State"?

Post by david1234 »

me again .....

any more ideas?

what could be wrong ?
maybe missing permission ?

can some one post the full system setting needed to make the api work?
I'm not an expert - so maybe I'm missing a simple setting ?
can't be that hard to make this work

Thanks ,
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: create a code that change the "Running State"?

Post by SteveGilvarry »

Example in documentation
curl -XPOST -d "user=yourusername&pass=yourpassword" https://yourserver/zm/api/host/login.json
Your test
curl -XPOST -d "user=David&pass=DavidPass" http://10.0.0.105/zm/api/login.json

curl -XPOST -d "user=David&pass=DavidPass" http://10.0.0.105/zm/api/host/login.json

Don't look in the api folder for files to match your URL, they are in code.

If that does work then
https://zoneminder.readthedocs.io/en/st ... abling-api
Options->System
Check OPT_USE_API
And ensure you have a secret key AUTH_HASH_SECRET

Also if you are using zmninja that will be a good indicator that you have a working api.
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
david1234
Posts: 96
Joined: Wed Jun 26, 2019 12:24 pm

Re: create a code that change the "Running State"?

Post by david1234 »

when I try to use https
I get this replay

Code: Select all

curl: (7) Failed to connect to 10.0.0.105 port 443: Connection refused
do I need to enable https? if yes - how to?

OPT_USE_API is check
and I enter AUTH_HASH_SECRET - but how is using it ? where do I need to enter it also
mayeb this is the problem?

I have try with "zmninja" , I get error that auth is wrong or something
Post Reply