Hello, I’m strugling to connect my alarm system via Rest interface. The problem that it could be connected only as LAN connected device.
I’m trying to use HubAction from both SmartApp and DeviceHandler but not able to get a response back. Hub version #3. I wonder if I should contact the support of something wrong with my code? Here is it
try {
def hubAction = new physicalgraph.device.HubAction(
[
method: “GET”,
path: “/ISAPI/Event/triggers/”,
headers: [
HOST: “192.168.0.220”, //IP of my device
Authorization: “Basic XXXXXtaWXXXX9uZGFWZXXX”
]
],
null, //hub.id - sending actual hub id does not help as well
[ callback: handleResponse ]
)
sendHubCommand(hubAction)
}
catch (Exception e) {
logger(“postToInfluxDB(): Exception {e} on {hubAction}”,“error”)
}
def handleResponse(physicalgraph.device.HubResponse hubResponse) //Never called with respose
The same story with Device handler
Add physical device in Service Manager smart app
def hub = location.hubs[0]
def DNI = “192.168.0.220”
def childDevice = addChildDevice(“myspace”, “MyAlarmDevice”, DNI, hub.id, [name: app.label, label: app.label, data: [“mac”: “4CBD8F64AED1”, “ip”: “192.168.0.220” , “port”: “80”], completedSetup: true]) //ip": “C0A800DC0” , “port”: “50” - wont work as well
def result = new physicalgraph.device.HubAction(
method: “GET”,
path: “/ISAPI/Event/triggers/”,
headers: headers,
//body: “{test JSON}”,
protocol: physicalgraph.device.Protocol.LAN
/callback: parse/
/“C0A800DC:50”/
)
return result
}
def parse(description) //Never called back.
Could someone help with what is wrong with my code?
I’m a bit rusty with this, but the key is usually to get the DNI of the device correct.
If you are just expecting a response to a request, setting the DNI to the hex encoded IP:PORT used to communicate with the device usually works e.g. C0A8004C:1BB0.
Alternatively use the MAC e.g. F0455910B963 as that works for the above and for unsolicited messages from the device.
I’ve changed host my laptop to sniff requests. Now it is bit better. I have my parse method called. BUT ip looks weird: ip:00000192!!!
Can it be some UnPn issue or some caching issue?
6:19:32 PM: debug Parsing message:‘addressChangeType:01, mac:448500CED83F, ip:00000192, port:8080’
6:19:26 PM: debug GET /myLockTest LAN
Accept: /
User-Agent: Linux UPnP/1.0 SmartThings
HOST: 192.168.0.110:8080
Content-Type: application/json
Authorization: Basic YWRtaW46SG9uZGFWZWk1
debug Return device handler:
Why ip 00000192 instead of 192.168.0.110?
No request to my laptop but method parse called with message returned: “‘addressChangeType:01, mac:448500CED83F, ip:00000192, port:8080’”