Hey folks. I'm trying to write a driver to pull sensor data from my alarm panel. The panel has a locally accessible event stream for sensor events. The caveat is that I'm a complete novice. I've done some modification to existing drivers/apps in the past, but never written one from scratch. What I'm trying to do at this point is to just get the raw event stream into the Hubitat logs so I can start writing out the parsing and what-not. The issue is that I'm getting nothing back from the stream and I have no clue why. I've tried looking at some of the other drivers out there that are using the eventstream function, but haven't been able to get anywhere. Anyone able to nudge me in the right direction?
Here's the driver's code as it stands right now:
Summary
import groovy.json.*
def version() {"0.0.1"}
metadata {
definition (name: "ADC Stream", namespace: "rlelliott", author: "Ryan E.") {
command "streamStart"
command "streamStop"
}
}
void initialize(){
}
void streamStart() {
log.info("Starting eventStream()...")
try {
interfaces.eventStream.connect("10.21.83.35:12345", [ignoreSSLIssues:true,rawData:true])
} catch(e) {
log.warn "Broke"
log.warn e
}
}
def eventStreamStatus(String message) {
log.info(message)
}
void parse(String message){
try{
def data = new JsonSlurper().parseText(message)
log.info(data)
}
catch(e){
log.warn("Error parsing", e)
}
}
void streamStop() {
interfaces.eventStream.close()
log.info("Stopping eventstream")
}
Here's what I get in the logs:
Summary
[dev:604](https://10.22.83.200/logs#dev604)2022-06-29 12:28:46.795 pm [info](https://10.22.83.200/device/edit/604)Stopping eventstream
[dev:604](https://10.22.83.200/logs#dev604)2022-06-29 12:21:17.053 pm [info](https://10.22.83.200/device/edit/604)START: EventStream Started
[dev:604](https://10.22.83.200/logs#dev604)2022-06-29 12:21:17.027 pm [info](https://10.22.83.200/device/edit/604)Starting eventStream()...
And here is what the event stream looks like when I curl it from Windows:
Summary
PS C:\Program Files\PowerShell\7> curl -k https://10.21.83.35:12345 --http0.9
ACK
{"event":"ZONE_EVENT","zone_event_type":"ZONE_ACTIVE","version":1,"zone":{"status":"Open","zone_id":34},"requestID":"16c5060a-b1e8-4eed-8d10-4b25960d426d"}
{"event":"ZONE_EVENT","zone_event_type":"ZONE_UPDATE","zone":{"id":"CB91AA","type":"Door_Window","name":"Office Window","group":"entryexitdelay","status":"Open","state":"0","zone_id":34,"zone_physical_type":1,"zone_alarm_type":3,"zone_type":1,"partition_id":0},"version":1,"requestID":"53604c72-cb20-4be6-8708-8dc6668ec6e5"}
{"event":"ZONE_EVENT","zone_event_type":"ZONE_ACTIVE","version":1,"zone":{"status":"Closed","zone_id":4},"requestID":"4f1d933a-b81e-4089-ad41-8713481be6dd"}
{"event":"ZONE_EVENT","zone_event_type":"ZONE_ACTIVE","version":1,"zone":{"status":"Closed","zone_id":43},"requestID":"860870b3-a668-4cee-967a-b380d3ab552e"}
{"event":"ZONE_EVENT","zone_event_type":"ZONE_UPDATE","zone":{"id":"E7B8A2","type":"Door_Window","name":"Garage Door Outside","group":"entryexitdelay","status":"Closed","state":"0","zone_id":4,"zone_physical_type":1,"zone_alarm_type":3,"zone_type":1,"partition_id":0},"version":1,"requestID":"0e56a1f1-14e1-49ff-b870-7036215d9077"}