Questions on json and BI

znelbok

n3wb
Joined
Aug 11, 2015
Messages
24
Reaction score
2
I am testing out the json interface with BI - and I know next to nothing about json so bear with me.

I am having some luck in logging in - I get the session key, create the md5 hash and then I can log in.

I am stuck from there.

If I try to issue a command say camlist ("cmd":"camlist") to get the list of cameras I get a result of "fail".

I have read the help file but may have missed it, is there something else I need to send to the BI server with the command I want to use (do I need to send the login info I generated everytime).

Thanks (more to come as I continue exploring)
 

znelbok

n3wb
Joined
Aug 11, 2015
Messages
24
Reaction score
2
OK, to answer my own question I found the line in the login section

For all other commands, you must supply a valid "session" value as supplied by the login command.

So I can get replies back now from the system.

I am now trying to tell BI to do stuff, like change profiles and set the traffic light

How do I do that?

"session":"0a827629449e6a5c371240cc4de175f9","cmd":"status","signal":"0"

This is what I though should change the singal status to 0 (i.e. red traffic light) but BI does not change at all.

And how long does a session last for? at what point do I need to get a new session id?
 

Robert M

Young grasshopper
Joined
Jan 4, 2017
Messages
36
Reaction score
2
I'm working with the API now as well. If you're doing POSTS and sending valid session ID it should be working. I'm having no issue changing profiles. Try sending signal without the " quotes.. It may be interpreting that as a string vs integer. I had that issue with profile as well. I'm using PHP and I had to force the variable to integer and then it worked fine for me after that.
 

Don Couchman

Young grasshopper
Joined
Nov 6, 2017
Messages
73
Reaction score
11
OK, to answer my own question I found the line in the login section

For all other commands, you must supply a valid "session" value as supplied by the login command.

So I can get replies back now from the system.

I am now trying to tell BI to do stuff, like change profiles and set the traffic light

How do I do that?

"session":"0a827629449e6a5c371240cc4de175f9","cmd":"status","signal":"0"

This is what I though should change the singal status to 0 (i.e. red traffic light) but BI does not change at all.

And how long does a session last for? at what point do I need to get a new session id?
I am doing this on my system right now. How did you get/where did you get the session ID? I am getting result:fail. Thanks in advance.
 

znelbok

n3wb
Joined
Aug 11, 2015
Messages
24
Reaction score
2
when you send a login command with no data you are returned a session key. Use that to create the MD5 hash required and us it for subsequent requests.

Just to follow up on this I tried all this again about a month ago and got the same results - many commands would not work for me. Requests seemed to be OK, but commands to BI were not working.
 

dirk6665

BIT Beta Team
Joined
Feb 13, 2015
Messages
36
Reaction score
18
Location
Pennsylvania
For background ... I am a hardware techie guy - but have no experience with the JSON interface or how to even initiate. It seems very complicated if all you are looking to do is, say, throw a PTZ command - this is what I wish to do.... it would have been SO much simpler if we could have sent the commands through a executable command line or similar.

Here's my situation - I have a PTZ camera that is turned to face the driveway when a static camera senses motion in the driveway it issues a BI PTZ move command to the PTZ camera to swing it to also face the driveway. Ideally, the PTZ camera should "time out" and go back to its preset position - but it remains at "PTZ Preset 1" which is the driveway. I'd like to create a batch file and issue the commands to move to PTZ preset 1 ...wait X seconds ... then move to preset PTZ position 3.

I thought I could do this easily using the JSON interface - but then I discovered you need something like cURL and session ID's and blah blah - very intricate for just wanting to move a camera to a defined preset. If this can be done using JSON perhaps someone can enlighten me and prove to me that I am making this more difficult than what it actually is. Anyone who has a better idea - I am all ears and would appreciate some insight. It certainly would be nice to have nested commands built-in to BI.
 

Robert M

Young grasshopper
Joined
Jan 4, 2017
Messages
36
Reaction score
2
You can just interact with your camera directly probably. I do that for direct camera manipulation. You can't really just use a batch file because Windows doesn't have a command line web browser natively. You'd still need to install a windows version of curl or something similar to even interact with your camera directly. There's no CLI command provided because the developer is designing their product for current standards and if someone wants to do that level of customization typically they'll be able to work with a web api. That's my assumption at least.

For background ... I am a hardware techie guy - but have no experience with the JSON interface or how to even initiate. It seems very complicated if all you are looking to do is, say, throw a PTZ command - this is what I wish to do.... it would have been SO much simpler if we could have sent the commands through a executable command line or similar.

Here's my situation - I have a PTZ camera that is turned to face the driveway when a static camera senses motion in the driveway it issues a BI PTZ move command to the PTZ camera to swing it to also face the driveway. Ideally, the PTZ camera should "time out" and go back to its preset position - but it remains at "PTZ Preset 1" which is the driveway. I'd like to create a batch file and issue the commands to move to PTZ preset 1 ...wait X seconds ... then move to preset PTZ position 3.

I thought I could do this easily using the JSON interface - but then I discovered you need something like cURL and session ID's and blah blah - very intricate for just wanting to move a camera to a defined preset. If this can be done using JSON perhaps someone can enlighten me and prove to me that I am making this more difficult than what it actually is. Anyone who has a better idea - I am all ears and would appreciate some insight. It certainly would be nice to have nested commands built-in to BI.
 

42etus

n3wb
Joined
Sep 16, 2014
Messages
21
Reaction score
4
In the camera's PTZ/Control page, set the timeout to return to Preset 1 in the "Resume cycle............" box


Capture.PNG
 

dirk6665

BIT Beta Team
Joined
Feb 13, 2015
Messages
36
Reaction score
18
Location
Pennsylvania
Hi 42etus,

Yes - this is already set. I see some members mentioning BICommand ... do you know where I can obtain this executable? All the references of the file seem to time out as if the ages are missing or the URLs are outdated.

Thanks for the reply.

--EDIT--

I have located the executable and it has solved all of my issues with sending PTZ commands to BI ... wish this (or other macros) were built into BI for execution upon alerts. It has a plethora of options and great features - but is slightly lacking in customization using scripting -- unless, of course, you wish to learn JSON which I have found to be really difficult to deploy.
 
Last edited:
Top