I monitor my the level of propane in my tank by using a wifi-connected device called a TankUtility.
TankUtility has an API that I’ve been using to get readings into Smartthings and Grovestream.
It’s been working well until recently.
I believe that the token required expires (that’s what the error displayed is when I issue that command from a browser’s URL line).
The section of code that gets the data is:
def runCmd() {
def params = [
uri: "https://data.tankutility.com/api/devices/$deviceID?token=$token"
]
try {
httpGet(params) { resp ->
log.debug "response data: ${resp.data}"
log.debug "temperature: ${resp.data.device.lastReading.temperature}"
log.debug "level: ${resp.data.device.lastReading.tank}"
sendEvent (name: "temperature", value: (resp.data.device.lastReading.temperature).toInteger(), unit:"F")
sendEvent (name: "level", value: (resp.data.device.lastReading.tank).toFloat(), unit:"%")
}
} catch (e) {
log.error "something went wrong: $e"
}
}
The deviceID remains constants, and the following call will return a current/working token:
https://user:password@data.tankutility.com/api/getToken
Is there a way to get a token before each call for a reading?
Thank you!