That’s a bit odd really; I thought
JSONPATH($.xxx
defaulted to
JSONPATH($[0].xxx
by itself.
If you post your working htttp.cfg and Item definitions, it may help others later who run into similar problems.
That’s a bit odd really; I thought
JSONPATH($.xxx
defaulted to
JSONPATH($[0].xxx
by itself.
If you post your working htttp.cfg and Item definitions, it may help others later who run into similar problems.
http.cfg is unchanged. All is commented.
Item is here
String Camera1Motion "Camera 1 Motion [%s]" { http="<[http://192.168.XX.XX/api.cgi?cmd=GetMdState&user=admin&password=123456:1000:JSONPATH($[0].value.state)]" }
But it is not the last edition. This “0” and “1” must be converted to “ON” and “OFF” and item type must be “switch” i think. Now i am looking for the way how to do it. It must be map transformation, but how to put it insode JSONPATH i can not understand.
Sure that you know)
Do it the other way around - use a javascript transform instead of JSONPATH transform, that does the JSON parsing and uses that to choose the return string ON/OFF
So i make an item this way
String MotionTest "Current Channel [%s]" { http="<http://192.168.178.36/api.cgi?cmd=GetMdState&user=admin&password=123456:1000:JS(getValue.js)]" }
but i am not good in javascript, need your help how do i parse it inside the getValue.js ?
There is an example in the HTTP binding docs, right alongside the JSONPATH example.
Yes i have found it but it do not work for me
My getValue.js
JSON.parse(input).$[0].value.state;
I made simple function like to check
(function(i){
return i;
})(input)
but it do not work(((
By the way Javascript Trans is installed http://prntscr.com/py5qa1
Made it!
Here is all
.item
Switch Camera1Motion "Camera 1 Motion [%s]" { http="<[http://192.168.XX.XX/api.cgi?cmd=GetMdState&user=admin&password=123456:1000:JS(cameraMotion.js)]" }
cameraMotion.js
(function(x){
var json = JSON.parse(x);
if (json[0].value.state)
{
result="ON";
}
else
{
result="OFF";
}
return result;
})(input)
.sitemap
Frame label="Camera Motion" {
Default item=Camera1Motion
}
rossko57, thanks for help!
Hello more of preformance Q…
@rossko57, i have set this up in node-red
working great! but i notice that its very fast going from true to false
i am planing on somthing like 12 cameras , and when my DIY alram is on
i am not home and , i will starting querying the the cameras
but still i am worried , will this kind of traffic damge/slow my network ?
what kind of intravel will you set ?
is there any way to make the camera change a litle slower
thanks!
I don’t know anything about node red, I’m afraid.
i was showing node red as an expmle …
i assume that the JS script also will send a GET request each time he wants a reply?
or maybe it is listening to changes?
just trying to understand if there is any diffrance between what i am doing and above…
The JS script doesn’t send anything. It just extracts data from incoming HTTP.
@thisisIO Item is set up to send HTTP request once a second.
so this approch will also send HTTP request each sec…to every camera
i am by no way a network expert, i am just asking
lets say 12 camers will send 12 requests in a sec time period (thats 1036800 a calls a day)
do you think this a problem ,or this is simaple request and the network can handle this ?
i have a beefy network switch , but maybe its worth looking on other approch
for now i just have two reolink camras …
Ethernet switches might be capable of 15,000 to a million packets per second. I do not think 24 packets (12 requests, 12answers) will stress it very much. But this is not a networking performance advice forum.
Whether you have to do this polling, or you can instead set up your cameras to send unsolicited messages in response to real events is a function of your cameras capabilities. There are only the two ways to do this.
wow great to hear now i can buy more cameras
lets just hope that node red is up to the task
thanks for all the help!
After some tests, i can say, that one second it is really not enought, it looses many movements.
But i thing the probem is not in switches, but in resources of platform that computes this requests.
Buy better a normal camera that sends movement by itself without polling (read - with support of motion detection by OH)
Realy to say, Reolink does it, but it do not supportted by OH, so you need to poll it.
do you know of such ?
i was sure the reolink is the one , but i am planing to buy 10 more so if you have any wisdom please share
maybe @matt1 can tell us what is the most feature rich for this kind of use
There is a topic in Community.
Search for something like ip camera binding. The biggest one. The is a list of compatible cams like dahua and so on.
Nativly reolink support it in onvif, but this binding do not work with it. I tested it for half year, maybe now smth changed. Read that thread.
I believe something has changed as we have a few users of reolink now using the binding.
@Gad_Ofir
The cameras with the most features are the ones that are both api and Onvif. This post Linked below breaks it down. I would not go for a non onvif camera as you gain a lot by having this as a bare minimum.