Page 1 of 1
Replacing native wunderground interface
Posted: Sunday 31 March 2019 11:34
by Number8
Hello,
In the quest to replace the native wunderground interface since wunderground policy change, I'm trying to get a dzvents script interprating the json value returned by the new api
returns this string
- Spoiler: show
- {"observations":{{["country"]="FR", ["metric"]={["elev"]=15, ["windGust"]=13, ["windChill"]=12, ["heatIndex"]=12, ["precipRate"]=0, ["temp"]=12, ["pressure"]=1017.61, ["precipTotal"]=0.25, ["dewpt"]=12, ["windSpeed"]=5}, ["lon"]=-2.34702134, ["lat"]=46.72182846, ["winddir"]=193, ["obsTimeLocal"]="2019-03-31 11:00:24", ["softwareType"]="weatherlink.com 1.10", ["obsTimeUtc"]="2019-03-31T09:00:24Z", ["humidity"]=97, ["qcStatus"]=-1, ["stationID"]="IPAYSDEL120", ["epoch"]=1554022824, ["neighborhood"]="Ile d'yeu port-joinville"}}}
returns
- Spoiler: show
- {{["lon"]=-2.34702134, ["neighborhood"]="Ile d'yeu port-joinville", ["stationID"]="IPAYSDEL120", ["epoch"]=1554024628, ["obsTimeLocal"]="2019-03-31 11:30:28", ["softwareType"]="weatherlink.com 1.10", ["lat"]=46.72182846, ["metric"]={["windGust"]=19, ["precipRate"]=0, ["windSpeed"]=5, ["pressure"]=1017.61, ["elev"]=15, ["windChill"]=12, ["heatIndex"]=12, ["temp"]=12, ["precipTotal"]=0.25, ["dewpt"]=12}, ["humidity"]=95, ["country"]="FR", ["winddir"]=150, ["qcStatus"]=-1, ["obsTimeUtc"]="2019-03-31T09:30:28Z"}}
How to I get for instance temp value and lon value?
Thank you
Re: Replacing native wunderground interface
Posted: Sunday 31 March 2019 19:23
by waaren
Number8 wrote: Sunday 31 March 2019 11:34
Hello,
In the quest to replace the native wunderground interface since wunderground policy change, I'm trying to get a dzvents script interprating the json value returned by the new api
returns this string
- Spoiler: show
- {"observations":{{["country"]="FR", ["metric"]={["elev"]=15, ["windGust"]=13, ["windChill"]=12, ["heatIndex"]=12, ["precipRate"]=0, ["temp"]=12, ["pressure"]=1017.61, ["precipTotal"]=0.25, ["dewpt"]=12, ["windSpeed"]=5}, ["lon"]=-2.34702134, ["lat"]=46.72182846, ["winddir"]=193, ["obsTimeLocal"]="2019-03-31 11:00:24", ["softwareType"]="weatherlink.com 1.10", ["obsTimeUtc"]="2019-03-31T09:00:24Z", ["humidity"]=97, ["qcStatus"]=-1, ["stationID"]="IPAYSDEL120", ["epoch"]=1554022824, ["neighborhood"]="Ile d'yeu port-joinville"}}}
returns
- Spoiler: show
- {{["lon"]=-2.34702134, ["neighborhood"]="Ile d'yeu port-joinville", ["stationID"]="IPAYSDEL120", ["epoch"]=1554024628, ["obsTimeLocal"]="2019-03-31 11:30:28", ["softwareType"]="weatherlink.com 1.10", ["lat"]=46.72182846, ["metric"]={["windGust"]=19, ["precipRate"]=0, ["windSpeed"]=5, ["pressure"]=1017.61, ["elev"]=15, ["windChill"]=12, ["heatIndex"]=12, ["temp"]=12, ["precipTotal"]=0.25, ["dewpt"]=12}, ["humidity"]=95, ["country"]="FR", ["winddir"]=150, ["qcStatus"]=-1, ["obsTimeUtc"]="2019-03-31T09:30:28Z"}}
How to I get for instance temp value and lon value?
Thank you
Happy to help if you send me the original call to wunderground via PM. The strings you supplied here are not interpreted by dz.utils.JSON as valid so I cannot test properly.
Re: Replacing native wunderground interface [Solved]
Posted: Sunday 31 March 2019 20:08
by Number8
Thanks @waaren. In the meantine I found the solution. I did not know that json table index starts at 1 and not 0
So the code is the following
Code: Select all
domoticz.log (item.json.observations[1].humidity)
domoticz.log (item.json.observations[1].metric.temp)
domoticz.log (item.json.observations[1].metric.pressure)
Re: Replacing native wunderground interface
Posted: Monday 01 April 2019 0:33
by Snowtiger
Not to spoil your fun or interfere with what your doing, but ......
In the current Bèta WU is back again using the new api.
Just for your information.
Re: Replacing native wunderground interface
Posted: Sunday 07 April 2019 9:56
by Number8
Yeap thank you but for the time beeing I'm far from upgrading. My system is in production (3 Domoticz instances) and I will upgrade at summer time when any problem that might arise during the process is not critical. I posted the whole script in examples folder.