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: 63
Joined: Wed Jun 26, 2019 12:24 pm

create a code that change the "Running State"?

Post by david1234 » Tue Jul 07, 2020 12:12 pm

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 ,

burger
Posts: 151
Joined: Mon May 11, 2020 4:32 pm

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

Post by burger » Fri Jul 17, 2020 1:21 am

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://<ipaddress>:554/path output.mp4
from terminal, and run through paths on ispydb or in zm hcl

If you are new to cctv, read this:
https://wiki.zoneminder.com/Dummies_Guide

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

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

Post by david1234 » Mon Jul 20, 2020 7:22 am

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: 63
Joined: Wed Jun 26, 2019 12:24 pm

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

Post by david1234 » Thu Jul 23, 2020 10:37 am

anyone?

burger
Posts: 151
Joined: Mon May 11, 2020 4:32 pm

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

Post by burger » Thu Jul 23, 2020 3:56 pm

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://<ipaddress>:554/path output.mp4
from terminal, and run through paths on ispydb or in zm hcl

If you are new to cctv, read this:
https://wiki.zoneminder.com/Dummies_Guide

bbunge
Posts: 2704
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

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

Post by bbunge » Sat Jul 25, 2020 8:14 pm

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: 63
Joined: Wed Jun 26, 2019 12:24 pm

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

Post by david1234 » Tue Jul 28, 2020 7:11 am

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: 63
Joined: Wed Jun 26, 2019 12:24 pm

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

Post by david1234 » Mon Aug 03, 2020 8:33 am

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: 445
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

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

Post by SteveGilvarry » Sun Aug 09, 2020 7:33 am

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.35.x
Random Selection of Cameras (Dahua and Hikvision)
More Dev VM's than I care to count.

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

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

Post by david1234 » Sun Aug 09, 2020 10:29 am

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

Who is online

Users browsing this forum: No registered users and 3 guests