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

Post Reply
marmachine
Posts: 128
Joined: Saturday 26 March 2016 10:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

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

Post by marmachine »

Well, i'm not going to work out all the details, you will need some programming skills for my suggestion!
Are you using the buienradar code i shared here recently by the way? That shouldn't be much of a problem regarding the time limitation though.

But anyway, just to explain a bit more, here's an example:

Code: Select all

--------------------------------------------------------------------------------------------------------------
-- API Wunderground call --
--------------------------------------------------------------------------------------------------------------

-- the below curl cmd stores json data to the file as defined in variable 'wuDataFile'

if (wuAPIstation) then

	-- where are we requesting data
	url = "http://api.wunderground.com/pws:'..wuAPIstation..'/'..country..'/'..city..'.json"
	-- create the full curl cmd string with output file and the above target url
	cmd = 'curl -Lo '..wuDataFile..' '..url

	-- perform the call
        local handle = os.execute(cmd)

        -- request result
        if handle then 
            -- curl result
                print("| CURL request was succesfull)
                print("| wuDataFile updated ....... : "..wuDataFile)
	end
end

Code: Select all

--------------------------------------------------------------------------------------------------------------
-- wuDataFile processing --
--------------------------------------------------------------------------------------------------------------

-- now in any script you can open the local file and get the data

-- open file and process data
local file = io.open(wuDataFile, "r")
local data=  file:read('*all')
file:close()
local jsonLocation = json:decode(data)  

-- get the values from the json data (the exact syntax ofcourse depends on the content of the json data)
local latitude              = jsonLocation.latitude
local longitude             = jsonLocation.longitude
local altitude              = jsonLocation.elevation

-- now you can do lots of things with the defined variables... obviously there's more than just three variables in my data, as this is just an example.

Minor note: the file and filepath should be allowed with full access for this to work!
User avatar
Brutus
Posts: 249
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Netherlands
Contact:

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

Post by Brutus »

Anyone having trouble getting data from Buienradar?

My tmp File is empty now, It gets opened every minute

I am using the new URL from buienradar.

Using: V3.5884
Last edited by Brutus on Saturday 12 November 2016 18:20, edited 1 time in total.
1x Intel NUC8i5BEK (Windows 10 x64) Domoticz on Virtualbox with DietPi.
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
28x Fibaro Modules
SMA Solar System
Daikin Airco / Heating
Denon DHT-S716H & DSW-1H
TinusExcentricus
Posts: 16
Joined: Friday 16 October 2015 16:06
Target OS: Linux
Domoticz version: 2023.1
Location: The Netherlands
Contact:

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

Post by TinusExcentricus »

Yep, same here. URL with arguments is working in browser, but Domoticz log sais:
Error: EventSystem: ~/domoticz/scripts/lua/script_time_rain.lua:93: attempt to compare number with nil
User avatar
Mooseknuckle
Posts: 43
Joined: Sunday 08 March 2015 9:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by Mooseknuckle »

Hi there,
I had the same problem. I changed the lat and lon values in my script to 2 decimals after the comma and it worked again:

Code: Select all

lat='52.51'
lon='4.66'
Maybe this will also work for you.
RPI 3, Philips Hue,Toon Thermostat, Harmony Smart Control, Yeelights
Mysensors wifi gateway + sensors, RFXtrx433E, Kaku stuff, Xiaomi gateway + sensors
Domoticz controlled DIY ambilight, Selectplus chime, Mi-light led controller
TinusExcentricus
Posts: 16
Joined: Friday 16 October 2015 16:06
Target OS: Linux
Domoticz version: 2023.1
Location: The Netherlands
Contact:

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

Post by TinusExcentricus »

Reducing lat/lon coordinates to 2 decimals doesn't work for me.
TinusExcentricus
Posts: 16
Joined: Friday 16 October 2015 16:06
Target OS: Linux
Domoticz version: 2023.1
Location: The Netherlands
Contact:

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

Post by TinusExcentricus »

The buienradar gadgets-url doesn't seem to work anymore.
SteGe
Posts: 40
Joined: Saturday 02 July 2016 13:54
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post by SteGe »

I have tried to reach the URL and the URLs on the buienradar site itself but both aren't giving any useful response. Maybe the problem is at buienradar?

Verstuurd vanaf mijn ONE A2003 met Tapatalk
Synology DS3615xs | Raspberry pi 3b |
RFXtrx433E | MySensors | Z-wave | Philips Hue | Ikea Tradfri |
Sunscreen | Power switches | Toon | Harmony | UE Smartradio |
Weatherstation | Doorbell | Letterbox reader | Lux | Temp | Humidity | Motion |
joshua
Posts: 9
Joined: Friday 22 August 2014 15:04
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

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

Post by joshua »

Mooseknuckle wrote:Hi there,
I had the same problem. I changed the lat and lon values in my script to 2 decimals after the comma and it worked again:

Code: Select all

lat='52.51'
lon='4.66'
Maybe this will also work for you.
it works for me, thanks
booster
Posts: 34
Joined: Wednesday 10 December 2014 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Rijssen, The Netherlands
Contact:

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

Post by booster »

Mooseknuckle wrote:Hi there,
I had the same problem. I changed the lat and lon values in my script to 2 decimals after the comma and it worked again:

Maybe this will also work for you.
Thanks, that helped for me...... weird it stopped working all of a sudden
Connected to:
-Pi3; Aeon Labs Z-Stick; Fibaro Switches, Roller Shutter and Motion Sensors; Qubino Dimmers; P1 Port + Youless, MiLight; HUE Bridge; Forest shuttle Z-Wave; RFLink + KAKU; Voltcraft CO20; Everspring floodsensors; GreenWave PN-6; NEO Sensors
User avatar
Brutus
Posts: 249
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Netherlands
Contact:

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

Post by Brutus »

It worked for me to. Thnx for the solution.

When you enter the "Old" URL in your browser it redirects to the shorter version:
OLD: http://gadgets.buienradar.nl/data/raint ... n=x.960975
NEW: http://gadgets.buienradar.nl/data/raint ... 9&lon=x.96
1x Intel NUC8i5BEK (Windows 10 x64) Domoticz on Virtualbox with DietPi.
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
28x Fibaro Modules
SMA Solar System
Daikin Airco / Heating
Denon DHT-S716H & DSW-1H
Rowdy
Posts: 7
Joined: Sunday 13 November 2016 13:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands (Almere)
Contact:

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

Post by Rowdy »

Hello,
I am trying to get this script working, but it is driving me nuts. :evil:

I get no data into the tmp file. i have try it like a event in domoticz, and try it like a script in the script/lua dir.
The rights are setting the right way 777 " 0 -rwxrwxrwx 1 pi pi 0 Nov 11 20:41 rain.tmp"
In the event log i get this error:
CURL Data request ........ : Failed
2016-11-13 14:40:31.298 LUA: ! CURL request .............. : curl -Lo /home/pi/domoticz/scripts/tmp/rain.tmp "http://gps.buienradar.nl/getrr.php?lat=52.35&lon=5.26"

But if i check the url i get data from buienradar " http://gps.buienradar.nl/getrr.php?lat=52.35&lon=5.26"
Like this :
000|14:55
000|15:00
000|15:05
000|15:10

So the url seems to work.

In the script u only change the settings for:
local latitude = 52.35 -- your home latitude, set as a user variable
local longitude = 5.26 -- your home longtitude, set as a user variable

The switch i let the name the same:
local rainswitchname = "Regen verwacht" -- (str) name for switch to toggle

And the IDX for my text switch
local idxRegenmmUur = 26 -- IDX for virtual (text) sensor

I do not understand what I'm doing wrong :( :?:

UPDATE..........

I have crackt this problem, it was a resolve problem "url: (6) Could not resolve host: gps.buienradar.nl"
When i look in the /etc/dhcpcd.conf file on the pi , i had a no static domain_name_servers.
Now it's working....
Happy :D :D :D
Last edited by Rowdy on Sunday 13 November 2016 20:08, edited 1 time in total.
Raspberry pi
RFXtrx433E
Sompfy sunscreen
Promax switches ( action)
Klik aan klik uit switches
must be added:
Ipcamera
motion sensors
Light switches Livolo
Thermometer
Smoke sensors
TinusExcentricus
Posts: 16
Joined: Friday 16 October 2015 16:06
Target OS: Linux
Domoticz version: 2023.1
Location: The Netherlands
Contact:

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

Post by TinusExcentricus »

Reducing lat en lon variables to 2 decimals works for me now. Server must have been down earlier or something. So this part of the code does the trick now:

-- config ---------------------------------------------------------
lat='1.12' -- lat/lon of your location
lon='1.12'
url='http://gadgets.buienradar.nl/data/raint ... lon='..lon
Hansbit
Posts: 36
Joined: Monday 17 February 2014 15:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by Hansbit »

Thanks. This solves the problem. Probably Buienrader changed something in their servers.
TinusExcentricus wrote:Reducing lat en lon variables to 2 decimals works for me now. Server must have been down earlier or something. So this part of the code does the trick now:

-- config ---------------------------------------------------------
lat='1.12' -- lat/lon of your location
lon='1.12'
url='http://gadgets.buienradar.nl/data/raint ... lon='..lon
DomoArie
Posts: 8
Joined: Tuesday 10 November 2015 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Netherlands
Contact:

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

Post by DomoArie »

It seems that allthough the url is correct now, I am not getting any data other than zeros... and this is happening all day already :-(
2016-11-15 21:24:00.525 LUA: Linetime: 21:55
2016-11-15 21:24:00.525 LUA: Line:000|22:00
2016-11-15 21:24:00.526 LUA: Linetime: 22:00
2016-11-15 21:24:00.526 LUA: Line:000|22:05
2016-11-15 21:24:00.526 LUA: Linetime: 22:05
2016-11-15 21:24:00.526 LUA: Line:000|22:10
2016-11-15 21:24:00.526 LUA: Linetime: 22:10
2016-11-15 21:24:00.526 LUA: Line:000|22:15
2016-11-15 21:24:00.526 LUA: Linetime: 22:15
2016-11-15 21:24:00.527 LUA: Line:000|22:20
2016-11-15 21:24:00.527 LUA: Linetime: 22:20
2016-11-15 21:24:00.527 LUA: Line:000|22:25
2016-11-15 21:24:00.527 LUA: Linetime: 22:25
2016-11-15 21:24:00.527 LUA: Line:000|22:30
mikeoo
Posts: 110
Joined: Sunday 22 March 2015 7:35
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Holland
Contact:

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

Post by mikeoo »

DomoArie wrote:It seems that allthough the url is correct now, I am not getting any data other than zeros... and this is happening all day already :-(
2016-11-15 21:24:00.525 LUA: Linetime: 21:55
2016-11-15 21:24:00.525 LUA: Line:000|22:00
2016-11-15 21:24:00.526 LUA: Linetime: 22:00
2016-11-15 21:24:00.526 LUA: Line:000|22:05
2016-11-15 21:24:00.526 LUA: Linetime: 22:05
2016-11-15 21:24:00.526 LUA: Line:000|22:10
2016-11-15 21:24:00.526 LUA: Linetime: 22:10
2016-11-15 21:24:00.526 LUA: Line:000|22:15
2016-11-15 21:24:00.526 LUA: Linetime: 22:15
2016-11-15 21:24:00.527 LUA: Line:000|22:20
2016-11-15 21:24:00.527 LUA: Linetime: 22:20
2016-11-15 21:24:00.527 LUA: Line:000|22:25
2016-11-15 21:24:00.527 LUA: Linetime: 22:25
2016-11-15 21:24:00.527 LUA: Line:000|22:30
Line 000 means no rain. So i depends on if it is raining on the LON and LAT place on that time. If it is raining and you are still getting 000 then.
check the URL you see in the logfile and paste it in your browser and see of you get the same values.

Working fine on my system so website is working fine. Maybe your LON/LAT are wrong.

Code: Select all

2016-11-16 07:28:00.612 LUA: Line:000|07:50
2016-11-16 07:28:00.612 LUA: Linetime: 07:50
2016-11-16 07:28:00.613 LUA: Line:000|07:55
2016-11-16 07:28:00.613 LUA: Linetime: 07:55
2016-11-16 07:28:00.613 LUA: Line:000|08:00
2016-11-16 07:28:00.613 LUA: Linetime: 08:00
2016-11-16 07:28:00.613 LUA: Line:000|08:05
2016-11-16 07:28:00.613 LUA: Linetime: 08:05
2016-11-16 07:28:00.613 LUA: Line:000|08:10
2016-11-16 07:28:00.614 LUA: Linetime: 08:10
2016-11-16 07:28:00.614 LUA: Line:035|08:15
2016-11-16 07:28:00.614 LUA: Linetime: 08:15
2016-11-16 07:28:00.614 LUA: Line:057|08:20
2016-11-16 07:28:00.614 LUA: Linetime: 08:20
2016-11-16 07:28:00.614 LUA: Line:106|08:25
2016-11-16 07:28:00.614 LUA: Linetime: 08:25
2016-11-16 07:28:00.615 LUA: Line:115|08:30
2016-11-16 07:28:00.615 LUA: Linetime: 08:30
2016-11-16 07:28:00.615 LUA: Line:070|08:35
2016-11-16 07:28:00.615 LUA: Linetime: 08:35
2016-11-16 07:28:00.616 LUA: Line:035|08:40
2016-11-16 07:28:00.616 LUA: Linetime: 08:40
2016-11-16 07:28:00.616 LUA: Line:080|08:45
2016-11-16 07:28:00.616 LUA: Linetime: 08:45
2016-11-16 07:28:00.616 LUA: Line:080|08:50
2016-11-16 07:28:00.617 LUA: Linetime: 08:50
2016-11-16 07:28:00.617 LUA: Line:080|08:55
2016-11-16 07:28:00.617 LUA: Linetime: 08:55
2016-11-16 07:28:00.617 LUA: Line:070|09:00
2016-11-16 07:28:00.617 LUA: Linetime: 09:00
2016-11-16 07:28:00.617 LUA: Line:087|09:05
2016-11-16 07:28:00.618 LUA: Linetime: 09:05
2016-11-16 07:28:00.618 LUA: Line:106|09:10
2016-11-16 07:28:00.618 LUA: Linetime: 09:10
2016-11-16 07:28:00.618 LUA: Line:112|09:15
2016-11-16 07:28:00.618 LUA: Linetime: 09:15 
TinusExcentricus
Posts: 16
Joined: Friday 16 October 2015 16:06
Target OS: Linux
Domoticz version: 2023.1
Location: The Netherlands
Contact:

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

Post by TinusExcentricus »

Looking at the logs it looks like url http://gadgets.buienradar.nl/data/raint ... 12lon=5.19 - even with only 2 decimals - doesn't seem to work at every polling. In other words; it's pretty unstable of late.
mikeoo
Posts: 110
Joined: Sunday 22 March 2015 7:35
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Holland
Contact:

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

Post by mikeoo »

TinusExcentricus wrote:Looking at the logs it looks like url http://gadgets.buienradar.nl/data/raint ... 12lon=5.19 - even with only 2 decimals - doesn't seem to work at every polling. In other words; it's pretty unstable of late.
Your link is not correct.
Wrong:

Code: Select all

http://gadgets.buienradar.nl/data/raintext?lat=52.12lon=5.19
Good:

Code: Select all

Good: http://gadgets.buienradar.nl/data/raintext?lat=52.12&lon=5.19
Missing the & before LON
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

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

Post by Egregius »

And I think they changed the URL again to

Code: Select all

http://gpsgadget.buienradar.nl/data/raintext/?lat=50.89&lon=3.11
Hmm, while posting this I test again to be sure. Some minutes ago the gadgets.buienradar... forwarded to gpsgadget... Now both seem to work.
TinusExcentricus
Posts: 16
Joined: Friday 16 October 2015 16:06
Target OS: Linux
Domoticz version: 2023.1
Location: The Netherlands
Contact:

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

Post by TinusExcentricus »

Indeed, both url's seem to work. Sorry for letting out the & in my url example. This wasn't the problem for the errors in my logs though, the & is there in the script. But not every polling succeeds. 20 minutes ago (16:20) it failed. The script polls every 5 minutes in my case.

I'm not sure which subdomain is best long term gadgets or gpsgadgets, but at the moment both are functional.
DomoArie
Posts: 8
Joined: Tuesday 10 November 2015 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Netherlands
Contact:

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

Post by DomoArie »

Hi
Both the urls will work and sure dont forget the & :-)
Since this morning I received real data back (it started to rain also), but the days before it wasnt providing the right data as it was raining at my location but buienradar was providing zerooooos.

So, a stable source? Hmmm
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest