Is it gonna rain within the next X minutes?

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by jvdz »

Ok, so did you check what it is set to? Probably All which makes it fire on each event, change that to Time to run it only one time per minute.
I've stated this before, but I wouldn't want to have these type of script in the event system, since it is single threaded and no other events will be processed during the running of this script.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Is it gonna rain within the next X minutes?

Post by poudenes »

Maybe i don't understand what you mean.

Here is the lua script im using:

Code: Select all

local RainTextIDX = 229   -- your domoticz text device
debug = false -- enable or disable debug output
tempfilename = '/home/osmc/domoticz/temp/Rain60.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=52.33&lon=4.87' -- 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=60
   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
Or do i rename the give event name? like regen-10 (every ten minutes ) ?
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by jvdz »

In the event editor on the right hand site of the window it shows LUA under the scriptname and under that probably ALL..... change that to Time.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Is it gonna rain within the next X minutes?

Post by poudenes »

jvdz wrote:In the event editor on the right hand site of the window it shows LUA under the scriptname and under that probably ALL..... change that to Time.

Jos
Thanks. Now i see it every minute. And gonna read also what the difference will be to the time/all/device/security etc... :)
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by jvdz »

That selection box just defines on which event the script is supposed to trigger. You had it so it triggers on All events, which is normally a LOT. ;)

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Is it gonna rain within the next X minutes?

Post by EdwinK »

Great. Now I've got it working again.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
BarryT
Posts: 369
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by BarryT »

poudenes wrote:2017-04-29 20:22:00.297 EventSystem: Script event triggered: REGEN 17.04.29
2017-04-29 20:22:00.410 EventSystem: Script event triggered: REGEN 17.04.29
2017-04-29 20:22:00.520 EventSystem: Script event triggered: REGEN 17.04.29
2017-04-29 20:22:00.674 EventSystem: Script event triggered: REGEN 17.04.29
2017-04-29 20:22:00.793 EventSystem: Script event triggered: REGEN 17.04.29
2017-04-29 20:22:00.906 EventSystem: Script event triggered: REGEN 17.04.29
2017-04-29 20:22:01.017 EventSystem: Script event triggered: REGEN 17.04.29
2017-04-29 20:22:12.113 EventSystem: Script event triggered: REGEN 17.04.29

Can someone help me with this... the script repeats many times... lots of lines like this for triggering Buitenrader to check if its gonna rain.
Did u use lua device or time?
*edit: its fixed allready :)
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by krizzz »

I only now noticed that you cannot put a notification fixed to the text device. DO you guys have any ideas how to get a notification so i can run outside and take me pillows from the garden when the rain comes in :)
BarryT
Posts: 369
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by BarryT »

krizzz wrote:I only now noticed that you cannot put a notification fixed to the text device. DO you guys have any ideas how to get a notification so i can run outside and take me pillows from the garden when the rain comes in :)
Then you need to edit the script.
This will do: switch a virtual device to 'on', send out a notification AND update the text idx when it will give some rain...

Change this

Code: Select all

   if (RainPrediction > 20  ) then
      verw = 3
      RainPredictionText=('('..round(RainmmHour, 1)..' mm) regen verwacht!')
   else 
      verw = 2
      RainPredictionText=('Voorlopig blijft het droog!')
   end
into

Code: Select all

   if (RainPrediction > 20  ) then
      verw = 3
      RainPredictionText=('('..round(RainmmHour, 1)..' mm) regen verwacht!')
      commandArray['SendNotification']='Regenscript#Regen verwacht'
      commandArray['Regenverwacht']='On'
   else 
      verw = 2
      RainPredictionText=('Voorlopig blijft het droog!')
    --commandArray['SendNotification']='Regenscript#Geen regen meer verwacht'
      commandArray['Regenverwacht']='Off'
   end
Don't forget to add a virtual switch named: Regenverwacht

I added a sendnotification for the no rain state as optional, but look out for this.
It is sending a notification every time the switch is updating (every minute).
If you want to use it, u need to remove the -- before the commandarray

*Edit:
Ofc you could also remove the notification part in the script, and do the notification from the device itself if you wish to use that :)
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by krizzz »

BarryT wrote:
krizzz wrote:I only now noticed that you cannot put a notification fixed to the text device. DO you guys have any ideas how to get a notification so i can run outside and take me pillows from the garden when the rain comes in :)
Then you need to edit the script.
This will do: switch a virtual device to 'on', send out a notification AND update the text idx when it will give some rain...

Change this

Code: Select all

   if (RainPrediction > 20  ) then
      verw = 3
      RainPredictionText=('('..round(RainmmHour, 1)..' mm) regen verwacht!')
   else 
      verw = 2
      RainPredictionText=('Voorlopig blijft het droog!')
   end
into

Code: Select all

   if (RainPrediction > 20  ) then
      verw = 3
      RainPredictionText=('('..round(RainmmHour, 1)..' mm) regen verwacht!')
      commandArray['SendNotification']='Regenscript#Regen verwacht'
      commandArray['Regenverwacht']='On'
   else 
      verw = 2
      RainPredictionText=('Voorlopig blijft het droog!')
    --commandArray['SendNotification']='Regenscript#Geen regen meer verwacht'
      commandArray['Regenverwacht']='Off'
   end
Don't forget to add a virtual switch named: Regenverwacht

I added a sendnotification for the no rain state as optional, but look out for this.
It is sending a notification every time the switch is updating (every minute).
If you want to use it, u need to remove the -- before the commandarray

*Edit:
Ofc you could also remove the notification part in the script, and do the notification from the device itself if you wish to use that :)
Super clear and thanks!!!!!

Only problem is now, when adding your code. I seem to have an error now in the script. The log shows

Code: Select all

017-05-05 21:48:00.246 Error: EventSystem: in regen_verwacht: [string "local RainTextIDX = 95 -- your domoticz tex..."]:58: unexpected symbol near '='
And my script now looks like this. I actually copy pasted your example into my script.

Code: Select all

local RainTextIDX = 95   -- your domoticz text device
debug = false -- enable or disable debug output
tempfilename = '/home/pi/domoticz/temp/Rain60.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=52.50&lon=4.80' -- 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=60
   RainPrediction = IsItGonnaRain(minuten)
   RainmmHour=10^((RainPrediction-109)/32)

   if (RainPrediction > 20  ) then
      verw = 3
      RainPredictionText=('('..round(RainmmHour, 1)..' mm) regen verwacht!')
      commandArray['SendNotification']='Regenscript#Regen verwacht'
      commandArray['regenverwacht']='On'
   else 
      verw = 2
      RainPredictionText=
      --commandArray['SendNotification']='Regenscript#Geen regen meer verwacht'
      commandArray['regenverwacht']='Off'
   end
   
   commandArray[2] = {['UpdateDevice'] = RainTextIDX .. '|0|' .. tostring(RainPredictionText)}

return commandArray
User avatar
mlamie
Posts: 122
Joined: Friday 25 October 2013 17:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: The Netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by mlamie »

I'm reading though this topic and I would like to ask if someone can help me and maybe others by updating the wiki page.
http://www.domoticz.com/wiki/Is_it_gonna_rain

I followed that page, and some things are missing like raintext device. I now only have a rain on/of switch. Help is much appreciated.
Raspberry Pi 3, RaZberry, RFXtrx433
Various Z-Wave devices, KlikAanKlikUit devices, ESP8266 NodeMCU, Sonoff POW and a Essent E-thermostaat
IP camera: Dahua 4MP IPC-HDBW4421R-AS, Vivotek FD8134V
BarryT
Posts: 369
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by BarryT »

krizzz wrote: Super clear and thanks!!!!!

Only problem is now, when adding your code. I seem to have an error now in the script. The log shows

Code: Select all

017-05-05 21:48:00.246 Error: EventSystem: in regen_verwacht: [string "local RainTextIDX = 95 -- your domoticz tex..."]:58: unexpected symbol near '='
And my script now looks like this. I actually copy pasted your example into my script.
Are you sure you did everything correct?
Please check UPPER and/or lowercase letters?
Please check the IDX of the text device for the rain?
I have tested the script and its working like it should do...
Did u use the script_time_regen_verwacht, and not used as a device?

Otherwise delete everything that has to do with the rain script, and start over again.
It's only 2 minutes work :)

**Edit: Please, look better next time.. You forget the line after "RainPredictionText=" :lol:

change

Code: Select all

verw = 2
      RainPredictionText=
      --commandArray['SendNotification']='Regenscript#Geen regen meer verwacht'
      commandArray['regenverwacht']='Off'
   end


into

Code: Select all

verw = 2
      RainPredictionText=('Voorlopig blijft het droog!')
      --commandArray['SendNotification']='Regenscript#Geen regen meer verwacht'
      commandArray['regenverwacht']='Off'
   end
Last edited by BarryT on Monday 08 May 2017 16:33, edited 3 times in total.
BarryT
Posts: 369
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by BarryT »

mlamie wrote:I'm reading though this topic and I would like to ask if someone can help me and maybe others by updating the wiki page.
http://www.domoticz.com/wiki/Is_it_gonna_rain

I followed that page, and some things are missing like raintext device. I now only have a rain on/of switch. Help is much appreciated.
Its not that hard.. Please check some pages back :)

Code: Select all

local RainTextIDX = 19 -- your domoticz virtual TEXT device (add virtual text device first, if you didnt do this allready and use its idx)
debug = false -- enable or disable debug output
tempfilename = '/home/pi/domoticz/scripts/barry/rain.tmp' -- be sure this is in the correct map, and give it chmod 0666
totalrain = 0
rainlines = 0

function IsItGonnaRain( minutesinfuture )
   url='http://gadgets.buienradar.nl/data/raintext/?lat=11.11&lon=11.11' -- this is important!! change the lat and lon to your needs! dont forget to add the 2 numbers behind the point!
   if debug then print(url) end
   read = os.execute('curl -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=30
   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
User avatar
mlamie
Posts: 122
Joined: Friday 25 October 2013 17:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: The Netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by mlamie »

BarryT wrote:
mlamie wrote:I'm reading though this topic and I would like to ask if someone can help me and maybe others by updating the wiki page.
http://www.domoticz.com/wiki/Is_it_gonna_rain

I followed that page, and some things are missing like raintext device. I now only have a rain on/of switch. Help is much appreciated.
Its not that hard.. Please check some pages back :)
If I understand it correctly this is a additional lua script or can it be combined with the one on the wiki? As soon I'm at home I will try and update the wiki page accordingly.
Raspberry Pi 3, RaZberry, RFXtrx433
Various Z-Wave devices, KlikAanKlikUit devices, ESP8266 NodeMCU, Sonoff POW and a Essent E-thermostaat
IP camera: Dahua 4MP IPC-HDBW4421R-AS, Vivotek FD8134V
BarryT
Posts: 369
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by BarryT »

mlamie wrote: If I understand it correctly this is a additional lua script or can it be combined with the one on the wiki? As soon I'm at home I will try and update the wiki page accordingly.
This is an stand-alone lua script.
You can make as many scripts as you attent to use but do not try to use the same devices in 2 or more scripts.
BarryT
Posts: 369
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by BarryT »

mlamie wrote:I followed that page, and some things are missing like raintext device. I now only have a rain on/of switch. Help is much appreciated.
It does not added automatically, so you need to add it manually as a "virtual" device.
First go to "hardware" and create a "dummy" group.
Now, in that dummy group you can add "virtual" devices.
Create a "text" device and give it a name.
Go to the devices page, and write down its "idx".
Use that IDX in the script as given before.

Dont forget to "accept new sensors/hardware" in settings page before making a virtual device.
Sometimes it doesnt work if you have turned it off..

G'Luck
Last edited by BarryT on Monday 08 May 2017 20:41, edited 1 time in total.
User avatar
mlamie
Posts: 122
Joined: Friday 25 October 2013 17:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: The Netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by mlamie »

Ok, I have both scripts, the one from the wiki and the second one in the post above as advised by BarryT. When I compare both are almost identical, but some differences are there. I'm not a programmer, is someone willing to combine them optimize and advise the final version?

For now it looks like both virtual devices work, p.s. both scripts do use the same rain.tmp file.
virtual device 1 = dummy switch 'Rain expected' - I also have a notification trigger
Image
virtual device 2 = dummy text 'regen verwacht'
Image

In the domoticz log:

every 15 min (wiki script - dummy switch 'Rain expected') which is saved in /home/pi/domoticz/scripts/lua :
2017-05-08 19:00:02.588 LUA: Regen verwacht: 0 mm binnen 20 minuten.

every min (forum script - dummy text 'regen verwacht') which I saved in the EventSystem:
2017-05-08 19:00:02.861 EventSystem: Script event triggered: regenverwacht

I sometimes see the error:
2017-05-08 19:15:10.406 Error: EventSystem: Warning!, lua script /home/pi/domoticz/scripts/lua/script_time_rain.lua has been running for more than 10 seconds

Can that aso be solved somehow?
Raspberry Pi 3, RaZberry, RFXtrx433
Various Z-Wave devices, KlikAanKlikUit devices, ESP8266 NodeMCU, Sonoff POW and a Essent E-thermostaat
IP camera: Dahua 4MP IPC-HDBW4421R-AS, Vivotek FD8134V
BarryT
Posts: 369
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by BarryT »

mlamie wrote:I sometimes see the error:
2017-05-08 19:15:10.406 Error: EventSystem: Warning!, lua script /home/pi/domoticz/scripts/lua/script_time_rain.lua has been running for more than 10 seconds

Can that aso be solved somehow?
Good to hear that its working now mlamie :)
If you get a "has been running for more than 10 seconds" please check your network/internet..
It tells you that it hasnt recieved any data after 10 seconds.

Occasionally i get the same warning, and its not that special..
Sometimes buienradar itself has difficulties on its server-side.
The same warning you can get from Weather Underground, Open Weather Map, or any other internet services when it doesnt recieve any or wrong data from the service within 10 seconds.

The reason of the 10 seconds is simple:
If a script is executed and it doesnt get any or corrupted data, it has to break the execute after 10 sec otherwise the system will hang as it cant do a new (script) job anymore.
After that it will re-start the hole scripting process again.

You can do a ping to a host or ping your raspberry to be sure your network is okay:
go to your windows, then cmd, and then the command: "ping -t 192.x.x.x"
You can use the ipaddress of your raspberry for internal network check or buienradar.nl for internet check, and wait some minutes.
If you recieved a time-out, then your network to the raspberry isnt that good or, when checked, even your internet has difficulties.

Log of today gives me 2 errors:

Code: Select all

2017-05-08 13:18:21.564 Error: Wunderground: Error getting http data!
(Explanation: I did a firmware upgrade on the router, so internet switched off for a couple seconds)

Code: Select all

2017-05-08 17:15:12.278 Error: EventSystem: Warning!, lua script regenverwacht has been running for more than 10 seconds
(Explanation: I did a reset on my switch after i added some new devices in my network)
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Is it gonna rain within the next X minutes?

Post by poudenes »

Thanks for the explanation ... Had same lines as well. And we all wanna try to remove them ... Don't like red lines haha...
Funny in the script you have a line

Code: Select all

read = os.execute('curl --connect-timeout 5 -s -o '..tempfilename..' "'..url..'"')  
I think it will disconnect after 5 sec if there is a timeout. And the script tells us its running for 10sec. Logical you will think after 5 sec it will break the connection and try it again later.
BarryT wrote:
mlamie wrote:I sometimes see the error:
2017-05-08 19:15:10.406 Error: EventSystem: Warning!, lua script /home/pi/domoticz/scripts/lua/script_time_rain.lua has been running for more than 10 seconds

Can that aso be solved somehow?
Good to hear that its working now mlamie :)
If you get a "has been running for more than 10 seconds" please check your network/internet..
It tells you that it hasnt recieved any data after 10 seconds.

Occasionally i get the same warning, and its not that special..
Sometimes buienradar itself has difficulties on its server-side.
The same warning you can get from Weather Underground, Open Weather Map, or any other internet services when it doesnt recieve any or wrong data from the service within 10 seconds.

The reason of the 10 seconds is simple:
If a script is executed and it doesnt get any or corrupted data, it has to break the execute after 10 sec otherwise the system will hang as it cant do a new (script) job anymore.
After that it will re-start the hole scripting process again.

You can do a ping to a host or ping your raspberry to be sure your network is okay:
go to your windows, then cmd, and then the command: "ping -t 192.x.x.x"
You can use the ipaddress of your raspberry for internal network check or buienradar.nl for internet check, and wait some minutes.
If you recieved a time-out, then your network to the raspberry isnt that good or, when checked, even your internet has difficulties.

Log of today gives me 2 errors:

Code: Select all

2017-05-08 13:18:21.564 Error: Wunderground: Error getting http data!
(Explanation: I did a firmware upgrade on the router, so internet switched off for a couple seconds)

Code: Select all

2017-05-08 17:15:12.278 Error: EventSystem: Warning!, lua script regenverwacht has been running for more than 10 seconds
(Explanation: I did a reset on my switch after i added some new devices in my network)
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
mlamie
Posts: 122
Joined: Friday 25 October 2013 17:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: The Netherlands
Contact:

Re: Is it gonna rain within the next X minutes?

Post by mlamie »

I checked the scripts used by me and they both do not have the 5 in the line as you mentioned...

Code: Select all

read = os.execute('curl -s -o '..tempfilename..' "'..url..'"')
Since I'm not a programmer is there someone willing to check, validate both scripts (wiki = switch device and this forum = text device). For now I have update the wiki page, but duplicates and inconsistencies in both scripts can be deleted I expect.

http://www.domoticz.com/wiki/Is_it_gonna_rain
Raspberry Pi 3, RaZberry, RFXtrx433
Various Z-Wave devices, KlikAanKlikUit devices, ESP8266 NodeMCU, Sonoff POW and a Essent E-thermostaat
IP camera: Dahua 4MP IPC-HDBW4421R-AS, Vivotek FD8134V
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest