I have an Myelas alarm system and i would lige to see the status on the system in openhab
when I call this adress:
172.0.0.1:8111/api/alarm/status
i get this status:
{“version”: 0.1, “devices”: {“panel1”: 100, “zone4”: 200}}
so this exempel is, panel1 100 ( partition ready) zone4 200 ( zone inactive)
i have this response types
ResponseTypes
100 : partition ready
110 : partition notready
120 : partition armed
130 : partition partarmed,
140 : partition alarm
200 : zone inactive
210 : zone active
220 :zone bypassed
230 : zone alarm
300 : zone closed
310 : zone open
320 : zone bypassed
330 : zone alarm
400 : zone clear
410 : zone smoke
420 : zone bypassed
500 : zone clear
510 : zone water
520 : zone bypassed
600 : zone clear
610 : zone carbonMonoxide,
620 : zone bypassed
Do the keys in the devices object always come back as panel1 and zone4, or can the keys change dynamically like zone6 or panel2? How to proceed depends on the answer. Also, are you on openHAB 1 or 2?
String PanelStatus "Panel Status [MAP(myelas.map):%s]" { http="<[myelas:60000:JSONPATH($.devices.panel1)]" }
String Zone4Status "Zone4 Status [MAP(myelas.map):%s]" { http="<[myelas:60000:JSONPATH($.devices.zone4)]" }
transform/myelas.map:
100 partition ready
110 partition notready
120 partition armed
130 partition partarmed
140 partition alarm
200 zone inactive
210 zone active
220 zone bypassed
230 zone alarm
300 zone closed
310 zone open
320 zone bypassed
330 zone alarm
400 zone clear
410 zone smoke
420 zone bypassed
500 zone clear
510 zone water
520 zone bypassed
600 zone clear
610 zone carbonMonoxide
620 zone bypassed
The repo you linked seems to contain code written in Python, with SmartThings integration in Groovy. Bindings in openHAB are written in Java. A quick glance at AlarmServer.py seems to indicate that it is communicating with https://www.myelas.com/ELAS/WebUI/Security/GetCPState and isn’t very complicated. This might make it a candidate to use the HTTP Binding directly, instead of having to write a new binding. Otherwise, having a binding replicate the function of AlarmServer.py looks pretty simple!
The approach would be to achieve the same HTTP request/responses you find in AlarmServer.py with the equivalent functions of the HTTP binding, assuming it’s all possible, which it might very well be. It might also need an assist from a rule and the sendHttpPostRequest action.
This line shows that JSON data is POSTed with username, password and alarm code, but I don’t know if that sets a cookie in Python which is used by subsequent calls. If so, it will probably need a binding instead of using the HTTP binding.
Someone with good Python knowledge and knowledge of the HTTP binding could try to match up requests and responses to see if the HTTP binding+rules+sendHttpPostRequest is viable, or if a new binding would be needed. In the more capable environment of Java and the Jetty HTTP client libraries, a fast and capable binding could be built with no doubt.
This would not work with JSON in the http adress and a transform to a switch item, right?
Like transforming a string of “unplugged” to Switch state OFF