Hi Guys,
I was wondering if anybody could help me write this script.
Essentially I need to parse a JSON response from a web API
The string looks like this:
Using hs.GetURLEx I have been able to go out to the website and return and write this JSON text to a local file which is half the battle.
The next step is to parse this string and assign the values to variables and then assign the variables to virtual devices so I can display them in HSTouch.
This is above my paygrade and I was wondering if I could get some help from some of the scripting experts. I have made some attempts with snippets of VB.net code that I have found on the net however nothing seems to run properly within homeseer.
I really don't care if it is the most elegant solution i.e. using the javascriptserializer (as it seems to not be supported in Homeseer2). I just need to extract the data and assign them to variables so that I can set device status/values
Any help on this is greatly appreciated
Thanks
BTW here is how far I have gotten (I know it is a mess)
I was wondering if anybody could help me write this script.
Essentially I need to parse a JSON response from a web API
The string looks like this:
Code:
{"energy_month":161651,"energy_week":137805,"system_id":123456,"source":"microinverters","energy_lifetime":297139,"summary_date":"2013-11-09T00:00:00-08:00","energy_today":15613,"current_power":146,"modules":22}
The next step is to parse this string and assign the values to variables and then assign the variables to virtual devices so I can display them in HSTouch.
This is above my paygrade and I was wondering if I could get some help from some of the scripting experts. I have made some attempts with snippets of VB.net code that I have found on the net however nothing seems to run properly within homeseer.
I really don't care if it is the most elegant solution i.e. using the javascriptserializer (as it seems to not be supported in Homeseer2). I just need to extract the data and assign them to variables so that I can set device status/values
Any help on this is greatly appreciated
Thanks
BTW here is how far I have gotten (I know it is a mess)
Code:
Sub Main(parm as object) Dim summaryurl Dim json = {"energy_month":161651,"energy_week":137805,"system_id":123456,"source":"microinverters","energy_lifetime":297139,"summary_date":"2013-11-09T00:00:00-08:00","energy_today":15613,"current_power":146,"modules":22} Dim ser As New Web.Script.Serialization.JavaScriptSerializer Dim summary = ser.Deserialize(Of jsonSummaryArray)(json) dim elapsedtime as string 'const website = "[URL]https://api.enphaseenergy.com/api/systems/123456/summary?key=ca1415287d8daf1988593ceb41de009b[/URL]" 's = hs.URLAction(website, "GET", "", "") 'hs.writelog("Info",s) summaryurl = hs.GetURLex("[URL="https://api.enphaseenergy.com/"]https://api.enphaseenergy.com[/URL]", "/api/systems/123456/summary?key=apikey1234567890", "", "443", "TRUE", "FALSE", "c:\enphasesummary.txt") hs.writelog("Info",summaryurl) hs.writelog("Info",summary) End Sub
Comment