kfischer628
(Kimberly Fischer)
December 2, 2018, 10:59pm
#1
after converting my openhab to version 2 (i am running 2.4 snapshot) on windows 10.
linkage8/linkage
the words “linkage” above are in <>
is part of my data that is returned in an item
Number nCheckCam1Alarm “Front Porch [MAP(onoffcam.map):%d]” { http="<[http://192.168.0.1:88/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=xxxxx&pwd=xxxxxx:4000:REGEX (.?(. ?).*)]" }
This used to make the item value 8 in openhab 1.x
In openhab 2 it never changes from its initital value of 0
vzorglub
(Vincent Regaud)
December 2, 2018, 11:21pm
#2
Can you post the whole data please?
kfischer628
(Kimberly Fischer)
December 3, 2018, 3:34am
#3
how do i post my results in this text box without it losing my formating? its removing the tags
<CGI_Result>
0
1
8
2
3
10
1
0
281474976710655
281474976710655
281474976710655
281474976710655
281474976710655
281474976710655
281474976710655
255
255
255
255
255
255
255
255
255
255
</CGI_Result>
vzorglub
(Vincent Regaud)
December 3, 2018, 7:26am
#4
See:
We all have to type this content over and over and over. Here is a posting we can all point to when the topic comes up.
Why use code fences?
Because rules, sitemap, logs, and configs are all but unreadable when code fences are not used.
When to use code fences?
Whenever one is posting any sort of code, config, log, and any text where line wrapping, indentation, and using an equal spaced font makes the text more legible.
How to use code fences?
Use 3 backticks (```)...
Or use <code>...
…
kfischer628
(Kimberly Fischer)
December 19, 2018, 4:30am
#5
Thanks…
Here is the openhab item
Number nCam1Alarm "Motion Detected [(%d)]" { http="<http://192.168.0.xxx:port/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=xxxxxxx&pwd=xxxxxxxx:4000:REGEX(.*?<motionDetectAlarm>(.*?)</motionDetectAlarm>.*)]" }
This is the result from the call when the http command is executed from a web browser.
<CGI_Result>
<result>0</result>
<IOAlarm>0</IOAlarm>
<motionDetectAlarm>1</motionDetectAlarm>
<soundAlarm>1</soundAlarm>
<record>0</record>
<sdState>0</sdState>
<sdFreeSpace>0k</sdFreeSpace>
<sdTotalSpace>0k</sdTotalSpace>
<ntpState>1</ntpState>
<ddnsState>0</ddnsState>
<url>http%3A%2F%2Fik5078.myfoscam.org%3A89</url>
<upnpState>1</upnpState>
<isWifiConnected>0</isWifiConnected>
<wifiConnectedAP></wifiConnectedAP>
<infraLedState>1</infraLedState>
</CGI_Result>
This worked in openhab 1.x…when motion was detected and the value changed to 2.
this rule never fires:
rule “cam 1 motion detect”
when
Item nCam1Alarm changed
then
…
Thanks in advance.
Kim
Regex is fine here, but rule and item file parsing is way more strict now in openHAB 2 then it was before. That means that any special character need to be escaped (colons for example). If you go to https://regex101.com/ and enter your regex, you will see a parser error for example.
Use the XPath transformation instead is my recommendation.
kfischer628
(Kimberly Fischer)
December 19, 2018, 2:04pm
#7
Thanks…by adding a \ to the regex in regex101.com … it seemed to work…but as soon as i add a backslash to my item file the whole item file has errors and it ignores my items completely.
so in my item i have
/motionDetectAlarm
changing that to
\/motionDetectAlarm
invalidates my entire item file.
kim
Yeah that is a longer story actually. You are using an openHAB 1 binding (http), so you must configure it in the item file. But the item file itself does not allow specific characters without escaping them (with a backslash).
So you basically need to double escape ("\\"). This problem will hopefully be gone with http2 in OH 2.5.
kfischer628
(Kimberly Fischer)
December 19, 2018, 2:24pm
#9
so i changed it to
<\\/motionDetectAlarm>
but now am back to square one as its not updating with value.
giving me a headache…gonna stop for a while and come back to it fresh later. thanks
Kim
kfischer628
(Kimberly Fischer)
December 19, 2018, 11:58pm
#10
Thanks again!! came back to it later (after a nap,lol). Uninstalled the http binding and reinstall it…working now with double backslash.
Thanks again
kim