Page 1 of 1

create a code that change the "Running State"?

Posted: Tue Jul 07, 2020 12:12 pm
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 ,

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

Posted: Fri Jul 17, 2020 1:21 am
by burger
This can be done w/API.

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

ctrl-f run state

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

Posted: Mon Jul 20, 2020 7:22 am
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,

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

Posted: Thu Jul 23, 2020 10:37 am
by david1234
anyone?

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

Posted: Thu Jul 23, 2020 3:56 pm
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.

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

Posted: Sat Jul 25, 2020 8:14 pm
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

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

Posted: Tue Jul 28, 2020 7:11 am
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 ,

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

Posted: Mon Aug 03, 2020 8:33 am
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 ,

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

Posted: Sun Aug 09, 2020 7:33 am
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.

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

Posted: Sun Aug 09, 2020 10:29 am
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