I'm trying to log an event that happens with a Smartthings device into a Firebase database. The function in my Smartthings app is:
def reportSwitchOnHandler(evt){
log.debug "reportSwitchOnHandler called: $evt"
def params = [
uri: "https://<project-id>.firebaseio.com/switchStateData/params.json?auth=<key>",
body: [
switchState: "test"
]
]
try {
httpPostJson(params) { resp ->
resp.headers.each {
log.debug "${it.name} : ${it.value}"
}
log.debug "DEBUG (POST FIREBASE): response contentType: ${resp. contentType}"
}
} catch (e) {
log.debug "something went wrong: $e"
}
My "params" database structure returned json is:
{"lights":0,"switchState":"off"}
I'm only wanting to update the switchState.
So with that said, when I run the above code, under the "params" structure, rather than updates the switchState child, it creates a new child with some random value like "-Kyn_TIEItKNNACLuEk5" and under that switchState is there with the "test" value.
{"-Kyn_TIEItKNNACLuEk5":{"switchState":"test"},"lights":0,"state":"off"}
Any ideas what I'm missing for it to actually update the original switchState child and not be creating a new sub child (-Kyn_TIEItKNNACLuEk5)?