Easy to use, 100% Lua-based event scripting framework.
Moderator: leecollings
Number8
Posts: 374 Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:
Post
by Number8 » 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
Debian buster on NUC and three RPi with buster.
waaren
Posts: 6028 Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:
Post
by waaren » Sunday 31 March 2019 19:23
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.
Last edited by
waaren on Sunday 31 March 2019 21:13, edited 1 time in total.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki
Number8
Posts: 374 Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:
Post
by Number8 » Sunday 31 March 2019 20:08
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)
Debian buster on NUC and three RPi with buster.
Snowtiger
Posts: 120 Joined: Tuesday 18 October 2016 13:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10915
Contact:
Post
by Snowtiger » Monday 01 April 2019 0:33
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.
Number8
Posts: 374 Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:
Post
by Number8 » Sunday 07 April 2019 9:56
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.
Debian buster on NUC and three RPi with buster.
Users browsing this forum: No registered users and 1 guest