Because I would like to integrate my Alarm System (Abus Secvest IP) into OpenHAB, I would like to read the status from its web GUI (and if possible change status).
Unfortunately I do not have a clue how to request the JSON information from the web GUI.
Actually I do not know how to check if the GUI supports JSON.
So it would be very helpful, if someone could get me hint how the syntax to request JSON from the Secvest Web GUI should look like.
My first item try looks like this:
String Abus_Status âStatus: [%s]â { http="<[http://user:password@192.168.178.24:8060/home.cgi?10000:JS(readABUS.js)]" }
and "readABUS.js is located in openhab/configurations/transform and looks like this
JSON.parse(input).CurrentMode;
(I saw somewhere in the html code the âCurrentModeâ but I donât know if this is included in the JSON response.
It isnât a stupid question at all. However, it will require someone who knows the Abus Secvest IP alarm system to help. It isnât a generic openHAB question.
But since it has a web GUI, you could write an XSLT transform to extract the information you want from the HTML if JSON is not available. There are several examples, mostly weather based parsing weather data from Yahoo in the wiki that might get you started.
thanks for your response (again)
I hope I will succeed as quick as last time when you provided some hints.
That said, I played around a little successfully
The source code of the Abus Web GUI contains:
var g_audio_path = â/sd/audio/english/â;
var g_audio_current_mode;
var g_sound_path = â/sd/audio/sounds/â
So far so goodâŠ
Unfortunately the variable I would like to extract is in a separate frame within âhome.cgiâ and I donât know how to search within the other frame for a phrase.
We are rapidly approaching the end of my knowledge about this, but I believe that each frame has its own URL (a frame is basically a web page embedded within another web page) so perhaps you can pull down the frame individually using that URL.
I really appreciate your help.
Actually I found out that your point is true (separate âoverview.cgiâ containing information I would like to read out (Status of Window sensors).
However, there is one part in the website where the activation switch for the security system is located.
I did not find the source code / separate URL of this switch, but I will keep digging
Another problem I did not find a solution for is:
How to convert a string to another type of variable.
e.g:
String Abus_Status âAbus Status: [%s]â { http="<[http:// ⊠/home.cgi:10000:REGEX(.?var CurrentMode="(.?)".*)]" }
will store âSetâ or âUnsetâ into the variable âAbus_Statusâ.
How do I convert it to a contact item?
There are two things you have to do. First is just declare it as a Contact instead of a String:
Contact Abus_Status ...
The second is you have to create a map to convert âSetâ to âOPENâ and âUnsetâ to âCLOSEDâ as a Contact only supports those two states. But my regular expression skills are not up to figuring out how to do that in the transform. Another way you can get around this is to leave Abus_Status as a String and create another Item Abus_Contact as a Contact and a rule to update the contact when Abus_Status updates.
rule "Update Abus Contact"
when
Item Abus_Status received update
then
if(Abus_Status.state == "Set") Abus_Contact.sendCommand(OPEN)
else Abus_Contact.sendCommand(CLOSED)
end
However I have problems reading the status of the window contacts etc.
There is a cgi returning the
values: http://192.168.178.24:8060/getOverviewStatus.cgi
This responds with a bunch of states:
InputCH1=OFF
InputCH2=OFF
InputCH3=OFF
InputVCH1=OFF
InputVCH2=DEACTIVATED
InputVCH3=DEACTIVATED
OutputCH1=OFF
OutputCH2=OFF
OutputWired=OFF
AlarmPowerFail=OFF
AlarmLowBattery=OFF
AlarmFault=OFF
AlarmFire=OFF
AlarmTechnical=OFF
AlarmBurglary=OFF
AlarmEntry=OFF
AlarmPanic=OFF
You will need to get the field using a regular expression transformation. There is an example on the http binding wiki page. Iâm afraid regex is not my thing and Iâll be of limited use figuring it out. I already have to start from scratch and relearn it every time.
I worked out the right queue of commands to filter the required information out of the list of variables mentioned in my previous post.
It took quite a while, but itâs working well - even if itâs not a beauty
In this command example mentioned below I just cut out the first variable to find the right syntax to integrate it into a proper rule (all other lines are deleted and will be used later:
executeCommandLine(Abus_ARRAY=âcurl -s http://root:xxx@192.168.178.24:8060/getOverviewStatus.cgi | awk âNR!=2 && NR!=3 && NR!=4 && NR!=5 && NR!=6 && NR!=7 && NR!=8 && NR!=9 && NR!=10 && NR!=11 && NR!=12 && NR!=13 && NR!=14 && NR!=15 && NR!=16 && NR!=17â | sed âs#^.*=##â > /var/log/openhab/abus.logâ);
The information (here: OFF) is extracted correctly, but I donât know how to store it into a variable.
Even better would be to store multiple Variables of the list above into an Array.
Any hint is greatly appreciated.
thanks for your quick reply.
So you mean, that you first generate the list of Strings and than separate THE SAME variable with .split?
Doesnât this lead to a conflict of different types of one single variable (string list / single string)?
import java.lang.String
rule ârequest Abus Secvest IP statusâ
when
Time cron â/3 * * * * ?"
then
var Abus_String = executeCommandLine("curl -s http://root:xxx@192.168.178.24:8060/getOverviewStatus.cgi | awk âNR!=3 && NR!=4 && NR!=5 && NR!=6 && NR!=7 && NR!=8 && NR!=9 && NR!=10 && NR!=11 && NR!=12 && NR!=13 && NR!=14 && NR!=15 && NR!=16 && NR!=17â | sed 's#^.=##ââ);
Abus_ARRAY.split(" ")
end
But I get an ERROR message in the openhab log:
Error during the execution of rule request Abus Secvest IP status
java.lang.RuntimeException: The name â.split()â cannot be resolved to an item or type.
Any idea?
Thanks.
NCO
Not weird. The cron trigger is set to go off every 3 seconds.
If you want every three minutes you want â* */3 * * * ?â.
Also, donât miss the comments above. You will want to add a timeout number as the second argument to the executeCommandLine or else you wonât get your string result back.
Damn it - you are right.
That kind of thing happens if I copy and pasteâŠ
I got your (and @danielwalters86) hint wrong and though I just need to add the timeout to the curl call.
Now I added 2000 ms to the exec command and will checkâŠ