Page 6 of 8
Re: updateWeatherSensors (yet another buienradar script)
Posted: Sunday 13 May 2018 15:11
by EdwinK
waaren wrote: ↑Sunday 13 May 2018 13:39
@Edwink,
thx but I don't know how to process the information from that site given the format it is presented in. For now I only process data that is presented in JSON or plain text format. If required I probably could also add some functions to process XML but processing HTML to get the required information is more than 1 bridge too far for my programming skills.
Too bad, but understandable. Will keep using it the way it is now. Who knows, someone else can work this.
Re: updateWeatherSensors (yet another buienradar script)
Posted: Sunday 08 July 2018 11:31
by patzzz
Feature request:
It would be nice if the script created a virtual device or environment variable which contains the amount of rain fallen in the last 12 hours.
So I can use that to decide whether or not my garden irrigation should turn on today or not.
Then I would combine that information with the amount of sunhours of (say) 25+ degrees celcius and I can water my garden only when needed.
Re: updateWeatherSensors (yet another buienradar script)
Posted: Sunday 08 July 2018 15:09
by waaren
patzzz wrote: ↑Sunday 08 July 2018 11:31
Feature request:
It would be nice if the script created a virtual device or environment variable which contains the amount of rain fallen in the last 12 hours.
So I can use that to decide whether or not my garden irrigation should turn on today or not.
Then I would combine that information with the amount of sunhours of (say) 25+ degrees celcius and I can water my garden only when needed.
My preference is to do this with this (separate) script that can also be used by anyone who updates their rainsensors by other scripts / hardware.
moved to new topic
http://www.domoticz.com/forum/viewtopic ... 72&t=24113
Re: updateWeatherSensors (yet another buienradar script)
Posted: Sunday 08 July 2018 20:08
by EdwinK
waaren wrote: ↑Sunday 08 July 2018 15:09
patzzz wrote: ↑Sunday 08 July 2018 11:31
Feature request:
It would be nice if the script created a virtual device or environment variable which contains the amount of rain fallen in the last 12 hours.
So I can use that to decide whether or not my garden irrigation should turn on today or not.
Then I would combine that information with the amount of sunhours of (say) 25+ degrees celcius and I can water my garden only when needed.
My preference is to do this with this (separate) script that can also be used by anyone who updates their rainsensors by other scripts / hardware.
- Spoiler: show
Code: Select all
-- setRainVar.lua for [ dzVents >= 2.4 ]
-- Before first execution create var "amountOfRainDuringLastHours" as type float
return {
on = { timer = { "every hour" }, -- Triggers the getJsonPart
httpResponses = { "setRainVar" } -- Trigger the handle Json part
},
logging = { level = domoticz.LOG_DEBUG,
marker = "setRainVar" },
execute = function(dz,trigger)
local rainDevice = dz.devices(128) -- name enclosed in quotes or number without quotes
local rainVar = dz.variables("amountOfRainDuringLastHours") -- name enclosed in quotes or number without quotes
local relevantHours = 12 -- below 24 we get the (graph) values for a day, above 23 we use year
local range = "day"
if relevantHours > 23 then range = "year" end
local function triggerJSON()
local URLString = dz.settings['Domoticz url'] .. "/json.htm?type=graph&sensor=rain&idx=" .. rainDevice.idx .. "&range=" .. range
dz.openURL({ url = URLString,
method = "GET",
callback = "setRainVar" })
end
local function setVar()
local Time = require('Time')
local now = Time()
local relevantAmount = 0
local delta,t
rt = trigger.json.result
if range == "year" then timeCompletion = " 00:00:00" else timeCompletion = ":00" end
for i=1,#rt do -- Loop through the result
t = Time(rt[i].d .. timeCompletion) -- get time and prepare for compare
delta = (t.compare(now).hours) -- diff in hours between json record and now
if delta <= relevantHours then
relevantAmount = relevantAmount + tonumber(rt[i].mm)
dz.log( "Date/time: " .. rt[i].d .. " ===>> Value in mm " ..
rt[i].mm .. " ===>> Delta hours: " .. delta ..
" ===>> Total until now: " .. relevantAmount
,dz.LOG_DEBUG)
end
end
rainVar.set(relevantAmount) -- Store value in uservariable
end
if trigger.isTimer or trigger.isDevice then
triggerJSON()
elseif trigger.ok then -- statusCode == 2xx
setVar()
else
dz.log("No valid response from domoticz",dz.LOG_ERROR)
end
end
}
- Spoiler: show
Code: Select all
setRainVar: An error occured when calling event handler Neerslag
2018-07-08 20:06:02.256 Status: dzVents: Error (2.4.6): setRainVar: .../domoticz/scripts/dzVents/generated_scripts/Neerslag.lua:36: attempt to get length of global 'rt' (a nil value)
What am I doing wrong, or is this because we didn't have rain for some time now?
Re: updateWeatherSensors (yet another buienradar script)
Posted: Sunday 08 July 2018 23:45
by waaren
EdwinK wrote: ↑Sunday 08 July 2018 20:08
Code: Select all
setRainVar: An error occured when calling event handler Neerslag
2018-07-08 20:06:02.256 Status: dzVents: Error (2.4.6): setRainVar: .../domoticz/scripts/dzVents/generated_scripts/Neerslag.lua:36: attempt to get length of global 'rt' (a nil value)
What am I doing wrong, or is this because we didn't have rain for some time now?
@EdwinK, No rain should not cause this error.
Could it be that the deviceName or IDX for rainDevice you are using is not of the type rain or that it is just created and /or no values are in the history in the hours to be reported (yet) ?
If it is of type rain and already in use for > 1 hour can you check the result of
http://domoticzIP:domoticzPort/json.htm?type=graph&sensor=rain&idx=nnn&range=day
Updated script at
http://www.domoticz.com/forum/viewtopic ... 72&t=24113
Re: updateWeatherSensors (yet another buienradar script)
Posted: Monday 09 July 2018 14:11
by EdwinK
Will reply in the new topic

, to keep this clean
Re: updateWeatherSensors (yet another buienradar script)
Posted: Tuesday 17 July 2018 17:53
by schulpr
Hi,
A few times per day I get the following error message:
2018-07-17 14:48:05.367 Error: Error opening url:
https://gadgets.buienradar.nl/data/rain ... 2&lon=5.47
2018-07-17 14:48:05.730 Error: dzVents: Error (2.4.7): WUS: [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
I assume that certain data is not available when the script runs. Is there a way to prevent this. Perhaps use the old data if the new is not available?
Kind regards, Rob
Re: updateWeatherSensors (yet another buienradar script)
Posted: Tuesday 17 July 2018 21:21
by waaren
schulpr wrote: ↑Tuesday 17 July 2018 17:53
Hi,
A few times per day I get the following error message:
2018-07-17 14:48:05.367 Error: Error opening url:
https://gadgets.buienradar.nl/data/rain ... 2&lon=5.47
2018-07-17 14:48:05.730 Error: dzVents: Error (2.4.7): WUS: [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
I assume that certain data is not available when the script runs. Is there a way to prevent this. Perhaps use the old data if the new is not available?
Kind regards, Rob
@schulpr
Rob, the first errormessage is from the main domoticz process telling us that the url could not be reached. I see this a couple of times a day. dzVents cannot check before firing the openURL that it will be successful so I cannot think of a way to prevent this.
The second errormessage is from dzVents telling that the return from the openURL contains no valid data and could not be processed. The design choice for this script is to ignore this and leave all values in the virtual sensors and switched as they were set in the previous run.
I assume that this is relative safe choice if we don't see these error messages flooding the logs.
Hope this clarifies
Re: updateWeatherSensors (yet another buienradar script)
Posted: Wednesday 18 July 2018 6:49
by schulpr
Hi @waaren,
Thanks for clarifying this. It's no problem but I like a clean error log

.
Kind regards,
Rob
Verzonden vanaf mijn iPad met Tapatalk
Re: updateWeatherSensors (yet another buienradar script)
Posted: Monday 06 August 2018 11:10
by poudenes
Hi All,
@Waaren Maybe a idea to have a option to disable all error logs? Because script is running perfect only sometimes no feedback from Buienradar:
Code: Select all
2018-08-05 21:24:04.833 Error: Error opening url: https://gadgets.buienradar.nl/data/raintext?lat=52.37&lon=4.90
2018-08-05 21:24:05.113 Error: dzVents: Error (2.4.7): [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
2018-08-05 23:00:09.531 Error: Error opening url: https://gadgets.buienradar.nl/data/raintext?lat=52.37&lon=4.90
2018-08-05 23:00:09.776 Error: dzVents: Error (2.4.7): [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
2018-08-06 01:24:04.696 Error: Error opening url: https://gadgets.buienradar.nl/data/raintext?lat=52.37&lon=4.90
2018-08-06 01:24:05.165 Error: dzVents: Error (2.4.7): [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
2018-08-06 05:00:22.172 Error: Error opening url: https://gadgets.buienradar.nl/data/raintext?lat=52.37&lon=4.90
2018-08-06 05:00:22.483 Error: dzVents: Error (2.4.7): [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
2018-08-06 05:48:04.152 Error: Error opening url: https://gadgets.buienradar.nl/data/raintext?lat=52.37&lon=4.90
2018-08-06 05:48:04.400 Error: dzVents: Error (2.4.7): [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
2018-08-06 06:12:04.141 Error: Error opening url: https://gadgets.buienradar.nl/data/raintext?lat=52.37&lon=4.90
2018-08-06 06:12:04.535 Error: dzVents: Error (2.4.7): [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
2018-08-06 09:00:23.044 Error: Error opening url: https://gadgets.buienradar.nl/data/raintext?lat=52.37&lon=4.90
2018-08-06 09:00:23.348 Error: dzVents: Error (2.4.7): [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
For a no issue and if i can disable this error then my Domoticz won't show any errors at all anymore

Re: updateWeatherSensors (yet another buienradar script)
Posted: Tuesday 07 August 2018 21:18
by waaren
poudenes wrote: ↑Monday 06 August 2018 11:10
Hi All,
@Waaren Maybe a idea to have a option to disable all error logs? Because script is running perfect only sometimes no feedback from Buienradar:
2018-08-05 21:24:04.833 Error: Error opening url:
https://gadgets.buienradar.nl/data/rain ... 7&lon=4.90
2018-08-05 21:24:05.113 Error: dzVents: Error (2.4.7): [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
For a no issue and if i can disable this error then my Domoticz won't show any errors at all anymore
As explained two posts before this. dzVents cannot prevent the "Error opening url:" message.
You can prevent the [0006] errormessage in the log by changing the lines starting with "dz.log(ERR.TRIGGERERROR" to commentlines by adding -- at the beginning of those lines.
Re: updateWeatherSensors (yet another buienradar script)
Posted: Tuesday 07 August 2018 21:38
by mAiden88
Will try this script tomorrow.. Thanks for share.
When its working, i will try to add "pollen" in this script. Can't promise it, i will try it.
Re: updateWeatherSensors (yet another buienradar script)
Posted: Wednesday 08 August 2018 10:53
by poudenes
waaren wrote: ↑Tuesday 07 August 2018 21:18
poudenes wrote: ↑Monday 06 August 2018 11:10
Hi All,
@Waaren Maybe a idea to have a option to disable all error logs? Because script is running perfect only sometimes no feedback from Buienradar:
2018-08-05 21:24:04.833 Error: Error opening url:
https://gadgets.buienradar.nl/data/rain ... 7&lon=4.90
2018-08-05 21:24:05.113 Error: dzVents: Error (2.4.7): [0006] Er is een probleem met inlezen van de data; controleer wat er fout is gegaan. in:WUS_rainForecastResponse, Error: 11699956
For a no issue and if i can disable this error then my Domoticz won't show any errors at all anymore
As explained two posts before this. dzVents cannot prevent the "Error opening url:" message.
You can prevent the [0006] errormessage in the log by changing the lines starting with "dz.log(ERR.TRIGGERERROR" to commentlines by adding -- at the beginning of those lines.
SORRY didn't saw the post. but thanks anyway !!
Re: updateWeatherSensors (yet another buienradar script)
Posted: Thursday 09 August 2018 14:08
by ArieKanarie
The first update works, but after that I get the following error:
Code: Select all
2018-08-09 14:07:01.569 Status: dzVents: Info: Handling httpResponse-events for: "WUS_addressResponse
2018-08-09 14:07:01.569 Status: dzVents: Info: WUS: ------ Start external script: updateWeatherSensors.lua: HTTPResponse: "WUS_addressResponse"
2018-08-09 14:07:01.685 Status: dzVents: Error (2.4.6): WUS: An error occured when calling event handler updateWeatherSensors
2018-08-09 14:07:01.685 Status: dzVents: Error (2.4.6): WUS: ...omoticz/scripts/dzVents/scripts/updateWeatherSensors.lua:1195: attempt to index field '?' (a nil value)
2018-08-09 14:07:01.685 Status: dzVents: Info: WUS: ------ Finished updateWeatherSensors.lua
Any idea?
Re: updateWeatherSensors (yet another buienradar script)
Posted: Thursday 09 August 2018 20:51
by waaren
ArieKanarie wrote: ↑Thursday 09 August 2018 14:08
The first update works, but after that I get the following error:
Code: Select all
2018-08-09 14:07:01.569 Status: dzVents: Info: Handling httpResponse-events for: "WUS_addressResponse
2018-08-09 14:07:01.569 Status: dzVents: Info: WUS: ------ Start external script: updateWeatherSensors.lua: HTTPResponse: "WUS_addressResponse"
2018-08-09 14:07:01.685 Status: dzVents: Error (2.4.6): WUS: An error occured when calling event handler updateWeatherSensors
2018-08-09 14:07:01.685 Status: dzVents: Error (2.4.6): WUS: ...omoticz/scripts/dzVents/scripts/updateWeatherSensors.lua:1195: attempt to index field '?' (a nil value)
2018-08-09 14:07:01.685 Status: dzVents: Info: WUS: ------ Finished updateWeatherSensors.lua
Any idea?
Have you entered your location in the domoticz settings ?
If so what do see if you enter
Code: Select all
http://maps.googleapis.com/maps/api/geocode/json?latlng=LATITUDE,LONGITUDE&sensor=true
(replace LATITUDE.LONGITUDE with actual values) in your browser ?
Re: updateWeatherSensors (yet another buienradar script)
Posted: Friday 10 August 2018 10:17
by ArieKanarie
To answer your questions, yes I specified location in domoticz, and I got a correct result when I tried the googleapis url.
But a night sleep did miracles, error is gone now.
Domoticz gets more human every day

Re: updateWeatherSensors (yet another buienradar script)
Posted: Friday 19 October 2018 10:06
by felix63
With no changes I now getting error from this script.
Code: Select all
2018-10-19 10:02:00.606 Status: dzVents: Info: ------ Finished status meteo
2018-10-19 10:02:01.009 Status: dzVents: Error (2.4.7): An error occured when calling event handler status meteo
2018-10-19 10:02:01.009 Status: dzVents: Error (2.4.7): ...oticz/scripts/dzVents/generated_scripts/status meteo.lua:1196: attempt to index field '?' (a nil value)
2018-10-19 10:02:01.009 Status: dzVents: Info: ------ Finished status meteo
Any idea what could cause this?
Re: updateWeatherSensors (yet another buienradar script)
Posted: Friday 19 October 2018 13:52
by waaren
felix63 wrote: ↑Friday 19 October 2018 10:06
With no changes I now getting error from this script.
Code: Select all
2018-10-19 10:02:00.606 Status: dzVents: Info: ------ Finished status meteo
2018-10-19 10:02:01.009 Status: dzVents: Error (2.4.7): An error occured when calling event handler status meteo
2018-10-19 10:02:01.009 Status: dzVents: Error (2.4.7): ...oticz/scripts/dzVents/generated_scripts/status meteo.lua:1196: attempt to index field '?' (a nil value)
2018-10-19 10:02:01.009 Status: dzVents: Info: ------ Finished status meteo
Any idea what could cause this?
Thanks for reporting !
In that area, the script tries to obtain your address from Google based on longitude / latitude.
The message return is now:
Code: Select all
"error_message": "Keyless access to Google Maps Platform is deprecated. Please use an API key with all your API calls to avoid service interruption. For further details please refer to http://g.co/dev/maps-no-account",
as a workaround change line 912 from
to
Code: Select all
if not(var.useDomoticzLocation) then
I will have to look into that how to solve this. Will do over the weekend
Re: updateWeatherSensors (yet another buienradar script)
Posted: Sunday 18 November 2018 14:20
by ronaldbro
Hi waaren,
first of all thanks for this script. This is very cool and helpful
Do you have an update of the previous post? I'm having the same error.
Code: Select all
2018-11-18 14:17:00.308 Status: dzVents: Info: WUS: ------ Start external script: updateWeatherSensors.lua:, trigger: every minute
2018-11-18 14:17:00.450 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2018-11-18 14:17:00.679 Status: dzVents: Info: Handling httpResponse-events for: "WUS_addressResponse
2018-11-18 14:17:00.679 Status: dzVents: Info: WUS: ------ Start external script: updateWeatherSensors.lua: HTTPResponse: "WUS_addressResponse"
2018-11-18 14:17:00.717 Status: dzVents: Error (2.4.8): WUS: An error occured when calling event handler updateWeatherSensors
2018-11-18 14:17:00.717 Status: dzVents: Error (2.4.8): WUS: ...omoticz/scripts/dzVents/scripts/updateWeatherSensors.lua:1195: attempt to index field '?' (a nil value)
Unfortunatly I'm still in the beginning of the learning curve to lua and dzVents, so I'm not a big help yet
Thanks for your help.
regards, Ronald
Re: updateWeatherSensors (yet another buienradar script)
Posted: Tuesday 27 November 2018 20:03
by waaren
ronaldbro wrote: ↑Sunday 18 November 2018 14:20
Hi waaren,
first of all thanks for this script. This is very cool and helpful
Do you have an update of the previous post? I'm having the same error.
Code: Select all
2018-11-18 14:17:00.308 Status: dzVents: Info: WUS: ------ Start external script: updateWeatherSensors.lua:, trigger: every minute
2018-11-18 14:17:00.450 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2018-11-18 14:17:00.679 Status: dzVents: Info: Handling httpResponse-events for: "WUS_addressResponse
2018-11-18 14:17:00.679 Status: dzVents: Info: WUS: ------ Start external script: updateWeatherSensors.lua: HTTPResponse: "WUS_addressResponse"
2018-11-18 14:17:00.717 Status: dzVents: Error (2.4.8): WUS: An error occured when calling event handler updateWeatherSensors
2018-11-18 14:17:00.717 Status: dzVents: Error (2.4.8): WUS: ...omoticz/scripts/dzVents/scripts/updateWeatherSensors.lua:1195: attempt to index field '?' (a nil value)
Unfortunatly I'm still in the beginning of the learning curve to lua and dzVents, so I'm not a big help yet
Thanks for your help.
regards, Ronald
Sorry missed this one until now.
The only way to solve this is by getting a google API key. If you have one I will explain how to use it.