Thanks. If 60 and 120 min works.. then its better then nothing for now
Ill follow this topic and see if the script will be updated !!
Siewert308SW wrote:@poudenes
It's a Lua script.
But forget about the script i amended.
After a closer look it aint working as i intended.
The 60 and 120min forecast are printed but are presenting the 30min prediction.
Need a closer look.
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave,Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
./script_time_rain.lua: line 1: ----------------------------------------------------------------------------------------------------------------: command not found
./script_time_rain.lua: line 2: syntax error near unexpected token `('
./script_time_rain.lua: line 2: `-- IsItGonnaRain( int minutesinfuture)'
EdKo66 wrote:Screen Shot 2017-04-25 at 21.23.34.pngGuess something is wrong :, because it's really raining outside.
I think its because it is an "rain radar" so it doesnt show the rainfall at the moment, but only in future, like IS it gonna rain in 30 minutes, and if yes how much..
lat & lon correct?
What does the log says?
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
EdKo66 wrote:Screen Shot 2017-04-25 at 21.23.34.pngGuess something is wrong :, because it's really raining outside.
I think its because it is an "rain radar" so it doesnt show the rainfall at the moment, but only in future, like IS it gonna rain in 30 minutes, and if yes how much..
lat & lon correct?
What does the log says?
Lat&lon are correct. Have accidentely deleted the logs, so can't tell.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
EdKo66 wrote:Screen Shot 2017-04-25 at 21.23.34.pngGuess something is wrong :, because it's really raining outside.
Which script are you using, could pass it here?
In order to see how you set it up.
Because i have the feeling that you have setup the rainfall below 60 while the round number is setup to 1 decimal or less behind the comma.
Meaning the script says "0.003mm rain expected" but your widget gets updated to 0 decimal behind the comma.
EdKo66 wrote:Screen Shot 2017-04-25 at 21.23.34.pngGuess something is wrong :, because it's really raining outside.
Which script are you using, could pass it here?
In order to see how you set it up.
Because i have the feeling that you have setup the rainfall below 60 while the round number is setup to 1 decimal or less behind the comma.
Meaning the script says "0.003mm rain expected" but your widget gets updated to 0 decimal behind the comma.
local RainTextIDX = 113 -- your domoticz text device
debug = false -- enable or disable debug output
tempfilename = '../var/packages/domoticz/scripts/lua/tmp/Rain.tmp' -- be sure this is in the correct map, and give it chmod 0666
totalrain = 0
rainlines = 0
function IsItGonnaRain( minutesinfuture )
url='http://gpsgadget.buienradar.nl/data/raintext/?lat=51.86&lon=4.41' -- this is important!! change the lat and lon to your needs!!
if debug then print(url) end
read = os.execute('curl --connect-timeout 5 -s -o '..tempfilename..' "'..url..'"') file = io.open(tempfilename, "r")
while true do
line = file:read("*line")
if not line then break end
if debug then print('Line:'..line) end
linetime=string.sub(tostring(line), 5, 9)
if debug then print('Linetime: '..linetime) end
linetime2 = os.time{year=os.date('%Y'), month=os.date('%m'), day=os.date('%d'), hour=string.sub(linetime,1,2), min=string.sub(linetime,4,5), sec=os.date('%S')}
difference = os.difftime (linetime2,os.time())
if ((difference > 0) and (difference<=minutesinfuture*60)) then
if debug then print('Line in time range found') end
rain=tonumber(string.sub(tostring(line), 0, 3))
totalrain = totalrain+rain
rainlines=rainlines+1
if debug then print('Rain in timerange: '..rain) end
if debug then print('Total rain now: '..totalrain) end
end
end
file:close()
averagerain=totalrain/rainlines
return(averagerain)
end
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
commandArray = {}
minuten=15
RainPrediction = IsItGonnaRain(minuten)
RainmmHour=10^((RainPrediction-109)/32)
if (RainPrediction > 20 ) then
verw = 3
RainPredictionText=('('..round(RainmmHour, 1)..' mm) regen verwacht!')
else
verw = 2
RainPredictionText=('Voorlopig blijft het droog!')
end
commandArray[2] = {['UpdateDevice'] = RainTextIDX .. '|0|' .. tostring(RainPredictionText)}
return commandArray
At the moment the script is spewing out errors '2017-04-29 19:20:01.901 Error: EventSystem: in Regen Verwacht: [string "local RainTextIDX = 113 -- your domoticz te..."]:13: attempt to index global 'file' (a nil value)', so I stopped it for now.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
Used your script and work great here. Now figure out to change the interval. Want change it so every 10min it will check at buienrader for rain. Now i see lot of loggings:
EdKo66 wrote:Screen Shot 2017-04-25 at 21.23.34.pngGuess something is wrong :, because it's really raining outside.
Which script are you using, could pass it here?
In order to see how you set it up.
Because i have the feeling that you have setup the rainfall below 60 while the round number is setup to 1 decimal or less behind the comma.
Meaning the script says "0.003mm rain expected" but your widget gets updated to 0 decimal behind the comma.
local RainTextIDX = 113 -- your domoticz text device
debug = false -- enable or disable debug output
tempfilename = '../var/packages/domoticz/scripts/lua/tmp/Rain.tmp' -- be sure this is in the correct map, and give it chmod 0666
totalrain = 0
rainlines = 0
function IsItGonnaRain( minutesinfuture )
url='http://gpsgadget.buienradar.nl/data/raintext/?lat=51.86&lon=4.41' -- this is important!! change the lat and lon to your needs!!
if debug then print(url) end
read = os.execute('curl --connect-timeout 5 -s -o '..tempfilename..' "'..url..'"') file = io.open(tempfilename, "r")
while true do
line = file:read("*line")
if not line then break end
if debug then print('Line:'..line) end
linetime=string.sub(tostring(line), 5, 9)
if debug then print('Linetime: '..linetime) end
linetime2 = os.time{year=os.date('%Y'), month=os.date('%m'), day=os.date('%d'), hour=string.sub(linetime,1,2), min=string.sub(linetime,4,5), sec=os.date('%S')}
difference = os.difftime (linetime2,os.time())
if ((difference > 0) and (difference<=minutesinfuture*60)) then
if debug then print('Line in time range found') end
rain=tonumber(string.sub(tostring(line), 0, 3))
totalrain = totalrain+rain
rainlines=rainlines+1
if debug then print('Rain in timerange: '..rain) end
if debug then print('Total rain now: '..totalrain) end
end
end
file:close()
averagerain=totalrain/rainlines
return(averagerain)
end
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
commandArray = {}
minuten=15
RainPrediction = IsItGonnaRain(minuten)
RainmmHour=10^((RainPrediction-109)/32)
if (RainPrediction > 20 ) then
verw = 3
RainPredictionText=('('..round(RainmmHour, 1)..' mm) regen verwacht!')
else
verw = 2
RainPredictionText=('Voorlopig blijft het droog!')
end
commandArray[2] = {['UpdateDevice'] = RainTextIDX .. '|0|' .. tostring(RainPredictionText)}
return commandArray
At the moment the script is spewing out errors '2017-04-29 19:20:01.901 Error: EventSystem: in Regen Verwacht: [string "local RainTextIDX = 113 -- your domoticz te..."]:13: attempt to index global 'file' (a nil value)', so I stopped it for now.
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave,Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
local RainTextIDX = 113 -- your domoticz text device
debug = false -- enable or disable debug output
tempfilename = '../var/packages/domoticz/scripts/lua/tmp/Rain.tmp' -- be sure this is in the correct map, and give it chmod 0666
totalrain = 0
rainlines = 0
function IsItGonnaRain( minutesinfuture )
url='http://gpsgadget.buienradar.nl/data/raintext/?lat=51.86&lon=4.41' -- this is important!! change the lat and lon to your needs!!
if debug then print(url) end
read = os.execute('curl --connect-timeout 5 -s -o '..tempfilename..' "'..url..'"')
file = io.open(tempfilename, "r")
while true do
line = file:read("*line")
if not line then break end
if debug then print('Line:'..line) end
2017-04-29 21:28:00.219 Error: EventSystem: in Regen Verwacht: [string "local RainTextIDX = '113' -- your domoticz ..."]:17: 'end' expected (to close 'while' at line 13) near
Screen Shot 2017-04-30 at 17.54.09.png (17.69 KiB) Viewed 2153 times
Last edited by EdwinK on Sunday 30 April 2017 17:55, edited 1 time in total.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
Is this triggered by the Event system? Internal or External files?
Internal -> Check the setting that it is Time in stead of All or Device.
External -> WHat is the script name ? something like script_time_xxx.lua?