I had a question a few days ago and csteele was nice enough to refer me to an app he wrote titled "Get Attributes App". Could someone please explain to me within the method "updateCheck()" when asynchttpGet() is executed what is the entry point that processes that. Does a driver method take that or does an entry point within the Hubitat OS execute or what? I am reading thru "Async HTTP calls" in the Developers doc's section but don't see the info.
Thanks For The Help
Apologies if I'm telling you something you already know here... but....
Developer's like @csteele are typically happy to answer people's questions, so don't feel too shy about tagging them (including the "at" symbol in front of their username), particularly if you have a question about something they developed (not that I want to guilt @csteele into answering your question , just a general tip). More generally, the convention is typically for people to post a question on the related topic with a "[Release]" prefix, if it is something the developer released for the Community to use. That doesn't appear to be the case in this instance, but again, just a handy tip in case you (or others) weren't aware. Not to say separate topics aren't allowed or are frowned upon, it just helps keep things in the one spot.
Anyway... Back to your question...
I am expecting you are referring to:
Specifically:
// Check Version ***** with great thanks and acknowledgment to Cobra (CobraVmax) for his original code ****
def updateCheck()
{
def paramsUD = [uri: "https://hubitatcommunity.github.io/GetAttributeApp/version2.json"]
asynchttpGet("updateCheckHandler", paramsUD)
}
In this example, the HTTP GET call is made to retrieve the .json file from GitHub, based on the URI of the paramsUD map. At the point that the HTTP request is sent, updateCheck() finishes and returns to the method that called it. When GitHub returns the .json file to the HE hub, the method mentioned in the first parameter of the asynchttpget call, updateCheckHandler, is called by the HE platform, passing in the HTTP response object HE received. This method appears in the code directly below the code snippet I posted above. You will see it checks the HTTP response status is ok, then proceeds to parse the HTTP response object.
I don't do this kind of development as my day job like others here, but have started to introduce it into some of my drivers. My understanding is that the benefit to this approach is that, unlike a httpget call, the asynchronous version means the HE hub is not tied up waiting for GitHub to issue it's response, which in some situations may take much longer than a simple returning of a file. In the async case the programmer can nominate what code to run once the response is received, allowing the thread processing the driver / app code to finish and free up resources while the response is being compiled and delivered by, in this case, GitHub.
To explain it in another way, an asynchronous call is where you send the request, get on with other things, then deal with the response when it comes in. A synchronous call is one where you issue a request, wait to receive the response before moving on. There are times where each one is relevant and needed, but, where there is no need to know the result of a request immediately or as part of a sequence of events, then it can be delayed until later, freeing up the hub for other work.
Hope that helps...
Thanks for the etequette suggestions. After your explanation I was able to digest more of the code... very appreciated. I figure at this rate I will totally understand this App by next year! LOL. The important thing I was looking for was that Device.capabilities, Device.supportedAttributes, and Device.supportedCommands give me the info I was looking for. I now know the methods associated with the Device Object is where I should have looked. Thanks For Your Help
No worries, glad to have moved you along in your understanding. I know I get similar incremental additions to my understanding of Groovy and HE the more I post and research here.... So keep up the questions as you continue.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.