I have a device that I would like to run local that only provides updates via http get in the following format. I can change the server and the url and nothing else including the port number. 80 only http://[server]/[url]/?x=22&y=33&z=44
From the docs it looks the device either needs to support changing the http server to port 39501 or it needs to support http put for hubitat to be able to parse the response into anything actionable. Is the only way to get this device to play nice with hubitat locally to build an intermediary to convert the request into something hubitat will accept or have I missed something?
No, you could build an app, which would listen on port 80, instead:
You would still need a device/driver (probably most easily one that is a child device of this app), but the app would be a "helper" for this aspect of the communication.
I'm using the test HTML endpoint app to test it out, but I'm not seeing the url parameters getting passed. how do I read the values of x,y and z?
Smartapp:
def var
mappings {
//the root path - you can also map other paths or use parameters in paths and posted data
path("/") { action: [ GET: "renderWebsite" ] }
}
def renderWebsite(){
log.info "Rendering page"
log.info "request: ${request}, data: ${request.uri}:${request.queryString}:${request.query}:${request.path}:${request.data}:${$params}"
html = "<html><head><title>Awesome Page</title></head><body><h1>hello world</h1></body></html>"
render contentType: "text/html", data: html, status: 200
}
Hmm, I'm not sure how this is different from how I was calling ${params}, but it worked and that's all that counts. THX for the assist!
Just incase it helps someone else, this is the output
Sadly, the device does not support removing the ? and with more testing it doesn't support adding / to build the url to hubitat either. I didn't think to check if I could add "/".
it's literally http://[server]/[url]?x=22&y=33&z=44 and [server], [url] are the only parts I can change and can only be alphanumerics, and very limited special characters. This device is SUPER frustrating
Thx for your help, but I think this will require a middle man to run locally with hubitat.
This is correct. I don't need the first value anyway and thought I could work around it, but w/o being to enter a forward slash on the actual device I can't point it to the correct hubitat url.