Configurable 'KNMI Weerlive' script
Posted: Thursday 16 May 2024 13:46
I hereby share the first edition of my new weather project.
I used Buienradar plugin for the weather, Weerlive script (for weather alerts) and Open meteo script (for wind and air quality forecast parameters).
Weerlive also offers the local data that I obtain from Buienradar. So I could reduce the number of sources I use.
The advantage of this is also that I can customize it entirely to my own taste.
The result is a huge script, that runs quite quickly:
So I expanded my Weerlive.nl weather alert and now it can fill the following devices with data:
(There is optional use of devices. You can skip wat you do not need by giving them a dummy idx of 99999 in the script.)
Weather and temperature devices: Text and Alert devides. The script can automatically change the (optional used and defined) custom icons. These icons correspond to the possible Weerlive 'image text'.
I still have to see how I can make the (optional) icons available. Some remarks:
I used Buienradar plugin for the weather, Weerlive script (for weather alerts) and Open meteo script (for wind and air quality forecast parameters).
Weerlive also offers the local data that I obtain from Buienradar. So I could reduce the number of sources I use.
The advantage of this is also that I can customize it entirely to my own taste.
The result is a huge script, that runs quite quickly:
Code: Select all
2024-05-16 13:10:00.302 Status: dzVents: Info: Weerlive-: ------ Start internal script: t-Weerlive:, trigger: "every 10 minutes"
2024-05-16 13:10:00.304 Status: dzVents: Info: Weerlive-: ------ Finished t-Weerlive
2024-05-16 13:10:03.365 Status: dzVents: Info: Weerlive-: ------ Start internal script: t-Weerlive: HTTPResponse: "weerlive"
2024-05-16 13:10:03.386 Status: dzVents: Info: Weerlive-: ------ Finished t-Weerlive
(There is optional use of devices. You can skip wat you do not need by giving them a dummy idx of 99999 in the script.)
Weather and temperature devices: Text and Alert devides. The script can automatically change the (optional used and defined) custom icons. These icons correspond to the possible Weerlive 'image text'.
I still have to see how I can make the (optional) icons available. Some remarks:
- Explanation of the api can be found at weerlive.nl, where you also can obtain an api key.
- You can do 300 calls per day. (In debug mode remaining number of calls is logged.)
- In the script you can see what devices it needs.
- The BARO device forcast uses the 'image' text that is found for tomorrow.
- Optional use of custom icons. Activate by setting local wl_icons_installed = 1.
NB. DOUBLE check function getIconNumber and correct your iconNumbers !!
Tip. Add icons alphabetically. (use same image names as in function 'getIconNumber') Manually add the first of these to a device.
To discover the CustomImage number run:to see all device information and search for your first icon by its name. There you find the number "CustomImage :"Code: Select all
https://yourIP:yourport/json.htm?type=command¶m=getdevices&plan=0
Then in the script you can alphabetically update the iconNumbers in the function 'getIconNumber' with the numbers that follow
- The Weatherforcast device gets the icon that comes with forcast tomorrow. May sometimes be a bit confusing with the text that is shown.
- The Rainforcast device gets the icon rain or NO rain, when not expected < 24 hours.
- The script translates mm rainfall to l/m2 which is easier to understand.
- The script calculates expected sun hours given as zond_perc_dag of the time between sunrise and sunset to hh:MM.
- An explanation about this can be found at KNMI
- Weerlive does not give the wind gust information. I have hardcoded this to 0 for the time being.
- I noticed that under the tab Other, the device has a wordwrap. When added to dashboard this is not the case.
Code: Select all
-- 12-05-2024 script by Jan Peppink, https://ict.peppink.nl
-- Started for weather alarm Expanded as renewed custom script instead of Buienradar.
-- Reduce the number of weather information sources.
--
-- Extra explaining comments and choices made ------------------------------------
-- Explanation of the api can be found at https://weerlive.nl/delen.php, where you also can obtain an api key.
-- Optional use of devices. You can skip them by giving them a dummy idx of 99999.
-- The BARO device forcast uses the 'image' text that is found for tomorrow.
-- WindGust is not yet part of weerlive api result. Hardcoded set to 0
-- Optional use of custom icons. Activate by setting wl_icons_installed = 1
-- NB. DOUBLE check function getIconNumber and correct your iconNumbers !!
-- The Weatherforcast device gets the icon that comes with forcast tomorrow.
-- May sometimes be a bit confusing with the text that is shown.
-- The Rainforcast device gets the icon rain or NO rain, when not expected < 24 hours.
-- The script translates mm rainfall to l/m2 which is easier to understand.
-- The script calculates expected sun hours given as zond_perc_dag of the time between sunrise and sunset to hh:MM.
-- An explanation about this can be found at https://www.knmi.nl/kennis-en-datacentrum/achtergrond/de-weersverwachting
--- Your settings ----------------------------------------------------------------
-- First set the used device index numbers and variables you might want to change.
---#################################################################
-- NB! To configure, set the devices you do NOT want to use to 99999
-- Easy to temporarily or permanently not use a device without rearanging the code.
---#################################################################
local wl_alarm_idx = 99999--idx of the custom Alert device for Weather alarm.
local wl_thb_idx = 99999--idx of the Temperature+humidity+barometer device adapter.
local wl_gtemp_idx = 99999--idx of the Temperature device adapter.
local wl_wind_idx = 99999--idx of the Wind device adapter.
local wl_zicht_idx = 99999--idx of the Visibility device.
local wl_gr_idx = 99999 --idx of the Global Solar radiation device adapter.
local wl_verw_idx = 99999--idx of the weatherforcast Text device.
local wl_rain_idx = 99999--idx of the Rain forcast Text device.
local wl_apikey = 'HereYourApiKey' -- Access for weerlive.nl with your apikey.
local wl_icons_installed = 0 -- 1 or 0 when custom icons have been installed or not.
----------------------------------------------------------------------------------
return {
on = {
timer = {
--'every 2 minutes', -- Only for testing.
'every 10 minutes',
},
httpResponses = {
'weerlive' -- matches callback string below
},
},
logging = {
-- Level can be domoticz.LOG_INFO, domoicz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG, domoticz.LOG_ERROR or domoticz.LOG_FORCE
level = domoticz.LOG_INFO,
--level = domoticz.LOG_DEBUG,
marker = 'Weerlive-',
},
execute = function(dz, triggeredItem)
-- Set Local environment=================
local _u = dz.utils -- Holds subset of handy utilities.
local _h = dz.helpers -- Holds the global functions
local _d = dz.globalData -- Holds the global data
-- Get location coordinates
local lat = dz.settings.location.latitude
local long = dz.settings.location.longitude
-- Use some color variables
local cGreen = '#008000;'
local cYellow = '#ffff00;'
local cOrange = '#ffa500;'
local cRed = '#ff0000;'
local cWhite = '#FFFFFF;'
local cBlue = '#0000FF;'
local cGrey = '#8d8d8d;'
local htmlColor = '#3b3bc4;'
--Adjust lineheight
local lineHeight = 1.1
local weeralarm_value = dz.devices(wl_alarm_idx).sensorValue -- Gets last stored value
local verw = '' --Holds weather forcast
local samenv = '' --Holds weather summary
local d1date = '' --Holds date for today
local d1nslperc = '' --Holds neerslperc for today
local d1znperc = '' --Holds sun perc for today
local d2date = '' --Holds date for tomorrow
local d2nslperc = '' --Holds neerslperc for tomorrow
local d2znperc = '' --Holds sun perc for tomorrow
local firstRain = 'norain' -- Holds first rain hour.
local lastRain = 'norain' -- Holds first rain hour.
local countRain = 0 -- Holds total expected rain in mm.
local rainText = '' -- Holds text to update rain forcast device.
-- Local Functions go here =============
local function gethumstat( lv )
-- Calculate the humidity status.
lv = tonumber( lv )
if lv < 35 then return dz.HUM_DRY
elseif lv >= 35 and lv < 45 then return dz.HUM_NORMAL
elseif lv >= 45 and lv < 55 then return dz.HUM_COMFORTABLE
elseif lv >= 55 and lv < 65 then return dz.HUM_NORMAL
else return dz.HUM_WET
end
end
local function getforecast( image )
-- Define the BARO forcast.
if image == "zonnig" or image == "helderenacht" then return dz.BARO_SUNNY
elseif image == "halfbewolkt" or image == "mist" or image == "lichtbewolkt" or image == "nachtmist" then return dz.BARO_PARTLYCLOUDY
elseif image == "bewolkt" or image == "zwaarbewolkt" or image == "wolkennacht" then return dz.BARO_CLOUDY
elseif image == "regen" or image == 'halfbewolkt_regen' or image == "buien" or image == "hagel" or image == "sneeuw" then return dz.BARO_RAIN
elseif image == "bliksem" then return dz.BARO_THUNDERSTORM
else
return dz.BARO_NOINFO
end
end
local function getIconNumber( image )
if image == 'bewolkt' then iconNumber = 121 end
if image == 'bliksem' then iconNumber = 122 end
if image == 'hagel' then iconNumber = 123 end
if image == 'halfbewolkt' then iconNumber = 124 end
if image == 'helderenacht' then iconNumber = 125 end
if image == 'lichtbewolkt' then iconNumber = 126 end
if image == 'mist' then iconNumber = 127 end
if image == 'nachtmist' then iconNumber = 128 end
if image == 'regen' or image == 'buien' or image == 'halfbewolkt_regen' then iconNumber = 129 end
if image == 'sneeuw' then iconNumber = 130 end
if image == 'wolkennacht' or image == 'nachtbewolkt' then iconNumber = 131 end
if image == 'zonnig' then iconNumber = 132 end
if image == 'zwaarbewolkt' then iconNumber = 133 end
-- For not existing image tekst called when no rain expected.
if image == 'geenregen' then iconNumber = 134 end
return iconNumber
end
local function getWindDirectionString( windDirection )
-- To calculate the windDirection.
local directionString = ''
-- When string is not in Enlish, the icon does not appear!
if windDirection >= 0 and windDirection < 11.25 then directionString = 'N' end
if windDirection >= 11.25 and windDirection < 33.75 then directionString = 'NNE' end
if windDirection >= 33.75 and windDirection < 56.25 then directionString = 'NE' end
if windDirection >= 56.25 and windDirection < 78.75 then directionString = 'ENE' end
if windDirection >= 78.75 and windDirection < 101.25 then directionString = 'E' end
if windDirection >= 101.25 and windDirection < 123.75 then directionString = 'ESE' end
if windDirection >= 123.75 and windDirection < 146.25 then directionString = 'SE' end
if windDirection >= 146.25 and windDirection < 168.75 then directionString = 'SSE' end
if windDirection >= 168.75 and windDirection < 191.25 then directionString = 'S' end
if windDirection >= 191.25 and windDirection < 213.75 then directionString = 'SSW' end
if windDirection >= 213.75 and windDirection < 236.25 then directionString = 'SW' end
if windDirection >= 236.25 and windDirection < 258.75 then directionString = 'WSW' end
if windDirection >= 258.75 and windDirection < 281.25 then directionString = 'W' end
if windDirection >= 281.25 and windDirection < 303.75 then directionString = 'WNW' end
if windDirection >= 303.75 and windDirection < 326.25 then directionString = 'NW' end
if windDirection >= 326.25 and windDirection < 348.75 then directionString = 'NNW' end
if windDirection >= 348.75 and windDirection <= 360 then directionString = 'N' end
return directionString
end
-- Now start to do something ============
-- Get the data.
if (triggeredItem.isTimer) then
-- Retrieve the data.
dz.openURL({
url = 'https://weerlive.nl/api/weerlive_api_v2.php?key=' .. wl_apikey .. '&locatie=' .. lat .. ',' .. long,
method = 'GET',
callback = 'weerlive'
})
end
if (triggeredItem.isHTTPResponse) then
-- Process the obtained data.
-- Check the response and process the data.
if (triggeredItem.ok and triggeredItem.isJSON) then
dz.log( 'Item and JSON - OK', dz.LOG_DEBUG )
-- We have some result. Store in table.
local result_table = triggeredItem.json
if type(result_table) == "table" then
dz.log( 'result_table: type = ' .. type(result_table), dz.LOG_DEBUG )
--- API ---------------------------------------
local api_table = result_table['api']
if type(api_table) == "table" then
dz.log( 'api_table: type = ' .. type(api_table), dz.LOG_DEBUG )
-- The data we get is:
-- "bron": "Bron: Weerdata KNMI/NOAA via Weerlive.nl",
-- "max_verz": 300,
-- "rest_verz": 90
local rest = api_table[1].rest_verz
dz.log( 'Remaining calls to weerlive.nl api for today = ' .. rest, dz.LOG_DEBUG )
else
dz.log( 'No api_table found', dz.LOG_ERROR )
end
--- LIVEWEER ---------------------------------
local liveweer_table = result_table['liveweer']
if type(liveweer_table) == "table" then
dz.log( 'liveweer_table: type = ' .. type(liveweer_table), dz.LOG_DEBUG )
-- The data we get is:
--"plaats": "Your City",
--"timestamp": 1714650484,
--"time": "02-05-2024 13:48:04",
--"temp": 23.2,
--"gtemp": 22.7,
--"samenv": "Licht bewolkt",
--"lv": 64,
--"windr": "O",
--"windrgr": 91.8,
--"windms": 2.14,
--"windbft": 2,
--"windknp": 4.2,
--"windkmh": 7.7,
--"luchtd": 998.851,
--"ldmmhg": 749,
--"dauwp": 16.1,
--"zicht": 27600,
--"gr": 796,
--"verw": "Vanaf vanmiddag onweersbuien. Vrijdag koeler weer met af en toe regen",
--"sup": "06:06",
--"sunder": "21:11",
--"image": "lichtbewolkt",
--"alarm": 0,
--"lkop": "Vanmiddag en vanavond plaatselijk overlast door onweersbuien",
--"ltekst": " Tot halverwege de middag zijn er geen waarschuwingen van kracht.Later vanmiddag en vanavond komen er vooral in het midden en zuiden onweersbuien voor. Deze buien kunnen plaatselijk gepaard gaan met windstoten, hagel en veel regen. Hierdoor kan er hinder zijn voor verkeer en buitenactiviteiten. Ook kan er plaatselijk wateroverlast zijn.Later in de avond neemt het aantal buien af en worden ze minder zwaar.Wat kan ik verwachten en wat kan ik doen?Meer detailsBij een onweersbui windstoten tot ca. 65 km/u. Hagel tot 2 cm. Daarnaast plaatselijk neerslaghoeveelheden van 20-40 mm in een uur.",
--"wrschklr": "groen",
--"wrsch_g": "02-05-2024 21:00",
--"wrsch_gts": 1714676400,
--"wrsch_gc": "geel"
-- TempHumBaro.
local temp = liveweer_table[1].temp -- Also used in with the wind device.
if wl_thb_idx ~= 99999 then
local lv = liveweer_table[1].lv
local status = gethumstat( lv )
local luchtd = liveweer_table[1].luchtd
-- Just a quick side trip here for tomorrow's image
dz.log( 'Image text for tomorrow = '.. result_table.wk_verw[2].image, dz.LOG_DEBUG )
local image = result_table.wk_verw[2].image
local forecast = getforecast( image )
dz.log( 'Update TempHumBaro: Temp: ' .. temp .. ', Hum: ' .. lv .. ', Status: ' .. status .. ', Luchtdr: ' .. luchtd .. ', Forecast:' .. forecast, dz.LOG_DEBUG )
dz.devices(wl_thb_idx).updateTempHumBaro( temp, lv, status, luchtd, forecast )
end
-- Apparent temperature
local gtemp = liveweer_table[1].gtemp -- Also used in with the wind device.
if wl_gtemp_idx ~= 99999 then
dz.log( 'Update gTemp: ' .. gtemp, dz.LOG_DEBUG )
dz.devices(wl_gtemp_idx).updateTemperature( gtemp )
end
-- Wind
if wl_wind_idx ~= 99999 then
local windms = _u.round( liveweer_table[1].windms, 1 )
local windrgr = liveweer_table[1].windrgr
local windDirectionString = getWindDirectionString( windrgr )
--local windGust = result_table.current.wind_gusts_10m
dz.log( 'Update Windgr : ' .. windrgr .. ', Winddirection' .. windDirectionString .. ', Wind m/s: ' .. windms .. ', Gust: 0' .. ', Temp: ' .. temp .. ', gTemp: ' .. gtemp, dz.LOG_DEBUG )
dz.devices(wl_wind_idx).updateWind( windrgr, windDirectionString, windms, 0, temp, gtemp )
end
-- Visibility
if wl_zicht_idx ~= 99999 then
local zicht = liveweer_table[1].zicht
dz.log( 'Update zicht: ' .. zicht / 1000, dz.LOG_DEBUG )
dz.devices(wl_zicht_idx).updateVisibility( zicht / 1000 )
end
-- Global radiation Watt/M2
if wl_gr_idx ~= 99999 then
local gr = liveweer_table[1].gr
dz.log( 'Update global radiation: ' .. gr, dz.LOG_DEBUG )
dz.devices(wl_gr_idx).updateRadiation( gr )
end
-- Weather alert
if wl_alarm_idx ~= 99999 then
local alarm = liveweer_table[1].alarm
local lkop = liveweer_table[1].lkop
local ltekst = liveweer_table[1].ltekst
local wrschklr = liveweer_table[1].wrschklr
local wrsch_g = liveweer_table[1].wrsch_g
local wrsch_gts = liveweer_table[1].wrsch_gts
local wrsch_gc = liveweer_table[1].wrsch_gc
local alertText = lkop
--Set the alert color
if wrschklr == 'rood' then
alertLevel = dz.ALERTLEVEL_RED
elseif wrschklr == 'oranje' then
alertLevel = dz.ALERTLEVEL_ORANGE
elseif wrschklr == 'geel' then
alertLevel = dz.ALERTLEVEL_YELLOW
else
alertLevel = dz.ALERTLEVEL_GREY
end
if wrsch_g ~= '-' then
-- There is a Warning
if wrsch_gc == 'rood' then
htmlbgColor = cRed
elseif wrsch_gc == 'oranje' then
htmlbgColor = cOrange
elseif wrsch_gc == 'geel' then
htmlbgColor = cYellow
else
htmlbgColor = cWhite
end
-- Add warning time and message on new line with the warning color.
alertText = alertText .. '\n<span style="line-height:' .. lineHeight .. '; background-color: ' .. htmlbgColor .. '">Vanaf ' .. wrsch_g .. ' geldt code ' .. wrsch_gc .. '.</span>'
end
-- Update the alert device with new alertLevel and alertText.
dz.log( 'Update Weeralarm: ' .. alertText, dz.LOG_DEBUG )
dz.devices(wl_alarm_idx).updateAlertSensor(alertLevel, alertText )
end
-- Summary and forecast used for wl_verw_idx
samenv = liveweer_table[1].samenv
verw = liveweer_table[1].verw
else
dz.log( 'No liveweer_table found', dz.LOG_ERROR )
end
---- WK_VERW ----------------------------------
local wk_verw_table = result_table['wk_verw']
if type(wk_verw_table) == "table" then
dz.log( 'wk_verw_table: type = ' .. type(wk_verw_table), dz.LOG_DEBUG )
-- The data we get is for 5 days, including today:
--"dag": "12-05-2024",
--"image": "halfbewolkt",
--"max_temp": 18,
--"min_temp": 17,
--"windbft": 3,
--"windkmh": 18,
--"windknp": 10,
--"windms": 5,
--"windrgr": 121,
--"windr": "ZO",
--"neersl_perc_dag": 50,
--"zond_perc_dag": 68
d1date = string.sub( wk_verw_table[1].dag, 1, 5 ) -- We use only 'dd-mm'
d1nslperc = wk_verw_table[1].neersl_perc_dag
d1znperc = wk_verw_table[1].zond_perc_dag
d2date = string.sub( wk_verw_table[2].dag, 1, 5 ) -- We use only 'dd-mm'
d2nslperc = wk_verw_table[2].neersl_perc_dag
d2znperc = wk_verw_table[2].zond_perc_dag
if wl_verw_idx ~= 99999 then
-- To calculate the expected sun hours.
local sunrise = dz.time.sunriseInMinutes
local sunset = dz.time.sunsetInMinutes
-- For today -------------------------------------
local suntimeMinutes = ( d1znperc / 100 ) * ( sunset - sunrise )
local sunHours = suntimeMinutes / 60
local integerPart, fractionalPart = math.modf( sunHours )
fractionalPart = _u.round( fractionalPart * 60, 0 )
local sunMinutes = string.format( "%02d", fractionalPart )
local sunTime = integerPart .. ':' .. sunMinutes .. ' uur'
dz.log( 'Calculated sun time today = ' .. sunTime, dz.LOG_DEBUG )
local d1mintemp = wk_verw_table[1].min_temp
local d1maxtemp = wk_verw_table[1].max_temp
-- arrowup = ▲ arrowdown = ▼ Degree celsius = ℃
local texta = d1date .. ': <span style="color: ' .. cGrey .. '">▼</span>Temp. ' .. d1mintemp .. ' ℃ - <span style="color: ' .. cGrey .. '">▲</span>Temp. ' .. d1maxtemp .. ' ℃ - Zon ' .. sunTime
dz.log( texta, dz.LOG_DEBUG )
-- For tomorrow ----------------------------------
local suntimeMinutes = ( d2znperc / 100 ) * ( sunset - sunrise )
local sunHours = suntimeMinutes / 60
local integerPart, fractionalPart = math.modf( sunHours )
fractionalPart = _u.round( fractionalPart * 60, 0 )
local sunMinutes = string.format( "%02d", fractionalPart )
local sunTime = integerPart .. ':' .. sunMinutes .. ' uur'
dz.log( 'Calculated sun time tomorrow = ' .. sunTime, dz.LOG_DEBUG )
local d2mintemp = wk_verw_table[2].min_temp
local d2maxtemp = wk_verw_table[2].max_temp
-- arrowup = ▲ arrowdown = ▼ Degree celsius = ℃
local textb = d2date .. ': <span style="color: ' .. cGrey .. '">▼</span>Temp. ' .. d2mintemp .. ' ℃ - <span style="color: ' .. cGrey .. '">▲</span>Temp. ' .. d2maxtemp .. ' ℃ - Zon ' .. sunTime
dz.log( textb, dz.LOG_DEBUG )
-- Summary and forcast text.
dz.log( 'Samenvatting: ' .. samenv, dz.LOG_DEBUG )
dz.log( 'Verwachting: ' .. verw, dz.LOG_DEBUG )
local verw_text = '<span style="color: ' .. htmlColor .. '">' .. samenv .. '\n' .. verw .. '</span>\n' .. texta .. '\n' .. textb
-- Update with new Text.
dz.log( 'Update Verwachting: ' .. verw_text, dz.LOG_DEBUG )
dz.devices(wl_verw_idx).updateText( verw_text )
if wl_icons_installed == 1 then
-- Update icon for tomorrow forecast.
local image = wk_verw_table[2].image
local iconNumber = getIconNumber( image )
dz.devices(wl_verw_idx).setIcon(iconNumber)
end
end
else
dz.log( 'No wk_verw_table found', dz.LOG_ERROR )
end
---- UUR_VERW ----------------------------------
local uur_verw_table = result_table['uur_verw']
if type(uur_verw_table) == "table" then
dz.log( 'uur_verw_table: type = ' .. type(uur_verw_table), dz.LOG_DEBUG )
-- The data we get is for 24 hr, starting from next whole hour:
--"uur": "13-05-2024 21:00",
--"timestamp": 1715626800,
--"image": "wolkennacht",
--"temp": 20,
--"windbft": 2,
--"windkmh": 7,
--"windknp": 4,
--"windms": 2,
--"windrgr": 130,
--"windr": "ZO",
--"neersl": 0,
--"gr": 6
if wl_rain_idx ~= 99999 then
-- Loop through the table. Search for the first rain occurence.
local tc = #uur_verw_table
for i = 1, tc do
-- if found: Rain expexted at 'uur'
-- else: No rain expected until (last time found.)
local neersl = uur_verw_table[i].neersl
local hr = uur_verw_table[i].uur
if neersl ~= 0 then
countRain = countRain + neersl
local unixTime = dz.time.dateToTimestamp( hr, 'dd-mm-yyyy hh:MM' )
if firstRain == 'norain' then firstRain = dz.time.timestampToDate( unixTime, 'hh:MM' , 0 ) end
lastRain = dz.time.timestampToDate( unixTime, 'hh:MM' , 3600 ) -- is the next hour.
else
if firstRain ~= 'norain' then
-- neersl == 0 after first episode of rain, so exit the loop.
break
end
end
end
if firstRain == 'norain' then
rainText = 'Geen neerslag verwacht < 24 uur'
dz.log( rainText, dz.LOG_DEBUG )
else
rainText = '<span style="color: ' .. htmlColor .. '">1<sup>e</sup> Neerslag (totaal ' .. countRain .. ' l/m<sup>2</sup>) tussen ' .. firstRain .. ' - ' .. lastRain .. ' uur</span>'
dz.log( rainText, dz.LOG_DEBUG )
end
local rainTexta = d1date .. ': Kans op neerslag ' .. d1nslperc .. '%.'
dz.log( rainTexta, dz.LOG_DEBUG )
local rainTextb = d2date .. ': Kans op neerslag ' .. d2nslperc .. '%.'
dz.log( rainTextb, dz.LOG_DEBUG )
-- Update with new Text.
dz.log( 'Update Regenverwachting: ' .. rainText .. '\n' .. rainTexta .. '\n' .. rainTextb, dz.LOG_DEBUG )
dz.devices(wl_rain_idx).updateText( rainText .. '\n' .. rainTexta .. '\n' .. rainTextb )
if wl_icons_installed == 1 then
if rainText == 'Geen neerslag verwacht < 24 uur' then
local iconNumber = getIconNumber( 'geenregen')
dz.devices(wl_rain_idx).setIcon(iconNumber)
else
-- Get rain icon
local iconNumber = getIconNumber( 'regen' )
dz.devices(wl_rain_idx).setIcon(iconNumber)
end
end
end
else
dz.log( 'No uur_verw_table found', dz.LOG_ERROR )
end
else
dz.log( 'No result_table found', dz.LOG_ERROR )
end
else
dz.log( 'Item or JSON - NOT OK', dz.LOG_ERROR )
end
end
end
}
-- That's All --------------------------------------------------