I use the HTTP Poller to get a weather forcast from openweathermap like this:
URL: http://api.openweathermap.org/data/2.5/ ... its=metric
The answer of this call is:
Code: Select all
<weatherdata>
<location>
<name>Berlin</name>
<type/>
<country>DE</country>
<timezone/>
<location altitude="0" latitude="52.524368" longitude="13.41053" geobase="geonames" geobaseid="0"/>
</location>
<credit/>
<meta>
<lastupdate/>
<calctime>0.103</calctime>
<nextupdate/>
</meta>
<sun rise="2016-11-23T06:43:36" set="2016-11-23T15:02:02"/>
<forecast>
<time from="2016-11-23T15:00:00" to="2016-11-23T18:00:00">
<symbol number="803" name="broken clouds" var="04n"/>
<precipitation/>
<windDirection deg="239.507" code="WSW" name="West-southwest"/>
<windSpeed mps="1.29" name="Calm"/>
<temperature unit="celsius" value="4.97" min="4.97" max="6.25"/>
<pressure unit="hPa" value="1028.4"/>
<humidity value="86" unit="%"/>
<clouds value="broken clouds" all="56" unit="%"/>
</time>
<time from="2016-11-23T18:00:00" to="2016-11-23T21:00:00">
<symbol number="803" name="broken clouds" var="04n"/>
<precipitation/>
<windDirection deg="310.001" code="NW" name="Northwest"/>
<windSpeed mps="1.33" name="Calm"/>
<temperature unit="celsius" value="5.17" min="5.17" max="6.03"/>
<pressure unit="hPa" value="1028.8"/>
<humidity value="88" unit="%"/>
<clouds value="broken clouds" all="64" unit="%"/>
</time>
.
.
.
Code: Select all
-- Retrieve the request content
s = request['content'];
-- Hole Wetterdaten
local t_from = domoticz_applyXPath(s,'//weatherdata/forecast/time/@from')
local temp = domoticz_applyXPath(s,'//weatherdata/forecast/time/temperature/@value')
local humidity = domoticz_applyXPath(s,'//weatherdata/forecast/time/humidity/@value')
local pressure = domoticz_applyXPath(s,'//weatherdata/forecast/time/pressure/@value')
local wb = domoticz_applyXPath(s,'//weatherdata/forecast/time/windDirection/@deg')
local wd = domoticz_applyXPath(s,'//weatherdata/forecast/time/windDirection/@code')
local ws = tostring(tonumber(domoticz_applyXPath(s,'//weatherdata/forecast/time/windSpeed/@mps'))*1.60934)
local wg = domoticz_applyXPath(s,'//weatherdata/forecast/time/windSpeed/@mps')
local clouds = domoticz_applyXPath(s,'//weatherdata/forecast/time/clouds/@all')
print('Time: '..t_from)
print('Temperatur: '..temp..' °C')
print('Feuchte: '..humidity..' %')
print('Druck: '..pressure..' hPa')
print('Windrichtung: '..wb..' ° '..wd)
print('Windgeschw.: '..ws..' km/h')
print('Wolken: '..clouds..' %')
--Barometer aktualisieren
domoticz_updateDevice(459,0,temp .. ";" .. humidity .. ";0;" .. pressure .. ";0")
--Wetter aktualisieren
domoticz_updateDevice(460,0,wb .. ";" .. wd .. ";" .. ws .. ";".. wg .. ";".. temp .. ";".. temp )
--Bewölkung in Prozent
domoticz_updateDevice(461,0,clouds)