@tomw thank you for your help! You were spot on in both of your observations. Between your points and an explanation I got from my friend I've made a ton of progress.
I am at the point where I am successfully getting the data back from Tigo, but when I do the "sendEvent" to update the value of the attribute I get this error: groovy.lang.MissingMethodException: No signature of method: com.hubitat.app.exception.LimitExceededException.
Below is the code I have as well as the logs. Any thoughts on what could be causing this problem?
Marc
Here is the code. The error happens at the "sendEvent".
def queryEnergyEndpoint() {
if (debug) { log.debug "Gathering energy metrics." }
def today = timeToday("00:00").format("YYYY-MM-dd")
def p_uri = "https://api2.tigoenergy.com/api/v3/data/summary?system_id=1111"
def p_headers = [ "Authorization": "Bearer xxxx" ]
try {
if (debug) log.debug "In try, executing httpget."
httpGet(
uri: p_uri,
headers: p_headers
) { r->
def summary = r.data.summary
if (debug) {
log.debug("Made it")
log.debug "Status: ${r.getStatus()}"
log.debug "Headers: ${r.getAllHeaders()}"
log.debug "Content Type: ${r.getContentType()}"
log.debug "Response: ${r.data}"
log.debug "summary: ${summary}"
}
def iproduction = summary.daily_energy_dc.toFloat().toInteger()
log.debug("Converted integer value: $iproduction")
if (debug) log.debug "production: ${summary.daily_energy_dc}"
if (debug) log.debug "iproduction: $iproduction"
sendEvent(name: "production", value: iproduction)
log.debug "production event sent"
}
} catch (Exception e) {
log.error "Exception"
if(e.getStatusCode()) {
switch(e.getStatusCode()) {
case 401:
log.error "401 - Not authorized"
break
case 403:
log.error "403 - Forbidden"
break
case 429:
log.error "429 - Too many requests"
break
default:
log.error "Unkown Error"
log.error "httpGet status code: e.getStatusCode ${e.getStatusCode()}"
log.error "httpGet message: e.message : ${e.message}"
log.error "httpGet full stack: e : ${e}"
break
}
}
}
Here are the logs
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.180 PM[error](http://hubitathub.local/logs#)groovy.lang.MissingMethodException: No signature of method: com.hubitat.app.exception.LimitExceededException.getStatusCode() is applicable for argument types: () values: [] on line 381 (method getEnergy)
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.153 PM[error](http://hubitathub.local/logs#)Exception
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.150 PM[debug](http://hubitathub.local/logs#)iproduction: 52851
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.148 PM[debug](http://hubitathub.local/logs#)production: 52851.95
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.145 PM[debug](http://hubitathub.local/logs#)Converted integer value: 52851
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.142 PM[debug](http://hubitathub.local/logs#)summary: [lifetime_energy_dc:103106572.79363, ytd_energy_dc:8619390.36, daily_energy_dc:52851.95, last_power_dc:0, updated_on:2023-08-19T18:06:00-07:00]
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.140 PM[debug](http://hubitathub.local/logs#)Response: [summary:[lifetime_energy_dc:103106572.79363, ytd_energy_dc:8619390.36, daily_energy_dc:52851.95, last_power_dc:0, updated_on:2023-08-19T18:06:00-07:00]]
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.137 PM[debug](http://hubitathub.local/logs#)Content Type: application/json
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.134 PM[debug](http://hubitathub.local/logs#)Headers: [date: Sun, 20 Aug 2023 01:18:56 GMT, server: Apache, upgrade: h2, connection: Upgrade, access-control-allow-origin: *, access-control-allow-headers: *, Authorization, x-app-version, Content-Type, access-control-expose-headers: X-APP-HAS-UPDATE, vary: Accept,Accept-Encoding, x-rate-limit-limit: 1000, x-rate-limit-remaining: 999, x-rate-limit-reset: 3, access-control-allow-credentials: false, set-cookie: _csrf=xxxx; path=/; domain=.tigoenergy.com; secure; HttpOnly; SameSite=Lax, x-content-type-options: nosniff, x-frame-options: sameorigin, content-type: application/json; charset=UTF-8, strict-transport-security: max-age=63072000]
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.130 PM[debug](http://hubitathub.local/logs#)Status: 200
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:57.127 PM[debug](http://hubitathub.local/logs#)Made it
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:56.822 PM[debug](http://hubitathub.local/logs#)In try, executing httpget.
[dev:1785](http://hubitathub.local/logs#)2023-08-19 06:18:56.820 PM[debug](http://hubitathub.local/logs#)Gathering energy metrics.