I'm on a mission to limit my Solar Inverter production to a minimal amount of WATTs. On reading up on a fellow home assistant integration work, I found the SMA Inverters may have a way of setting a key to get this done.
I've looked at asynchttpGet and asynchttpPut and do not see any output of a SID token, as this information is needed to generate the script.
https://172.16.1.199/dyn/setParamValues.json?sid=[mySID] Body: { "destDev": , "values": [ { "6802_00832B00" : { "1": [1000] } } ] } Cookie: tmhDynamicLocale.locale="en-gb"; deviceClass443="1"; user443= "role" : "bitMask" : 4, "title" : "istl" , "loginLevel" : 2} , username" : 862, "sid" : "[mySID]" }
I've looked at the headers and see nothing returned. Is there a way to open the http and grab a sid?
The Hubitat HTTP methods let you specify a header and body. It seems like what you want is in the body. Are up asking how to do that or how to get the information in the first place?
How do I get the SID?
bresponse data: hubitat.scheduling.AsyncResponse@10f51d8 << Is this the SID in Groovy?
(http://172.16.1.190/logs#) - aresponse data: [Content-type:text/html, Server:GoAhead-Webs, Cache-Control:no-cache, Pragma:no-cache, Date:Wed Jul 24 15:45:28 2024]
If the site was sending back vaild JSON it would be easier, but since it doesn't appear to given the snippet above you'll need to process the result as a string. So something similar to:
def makeReq() {
bodyMap = [grant_type:"client_credentials",client_id:"$userName", client_secret:"$pwd"]
def bodyText = JsonOutput.toJson(bodyMap)
Map requestParams =
[
uri: "https://172.16.1.199/dyn/setParamValues.json?sid=[$mySID]",
contentType: 'application/json',
body: "$bodyText"
]
asynchttpGet (requestParams, 'getResp')
}
def getResp(resp, data) {
sid=''
if(resp.getStatus() == 200 ){
if(resp.data){
rStr = resp.data
sidStart = rStr.indexOf('\"sid\"')+10
sidEnd = rStr.lastIndexOf(']')
sid = rStr.subString(sidStart,sidEnd)
}
}
}
1 Like