Page 7 of 16

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

Posted: Wednesday 28 September 2016 13:59
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!

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

Posted: Saturday 12 November 2016 17:54
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

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

Posted: Saturday 12 November 2016 18:01
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

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

Posted: Sunday 13 November 2016 11:54
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.

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

Posted: Sunday 13 November 2016 12:18
by TinusExcentricus
Reducing lat/lon coordinates to 2 decimals doesn't work for me.

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

Posted: Sunday 13 November 2016 12:24
by TinusExcentricus
The buienradar gadgets-url doesn't seem to work anymore.

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

Posted: Sunday 13 November 2016 12:33
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

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

Posted: Sunday 13 November 2016 13:48
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

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

Posted: Sunday 13 November 2016 14:03
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

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

Posted: Sunday 13 November 2016 15:07
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

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

Posted: Sunday 13 November 2016 15:13
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

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

Posted: Sunday 13 November 2016 17:27
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

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

Posted: Monday 14 November 2016 22:07
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

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

Posted: Tuesday 15 November 2016 21:27
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

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

Posted: Wednesday 16 November 2016 7:33
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 

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

Posted: Wednesday 16 November 2016 12:36
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.

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

Posted: Wednesday 16 November 2016 15:06
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

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

Posted: Wednesday 16 November 2016 15:33
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.

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

Posted: Wednesday 16 November 2016 16:42
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.

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

Posted: Wednesday 16 November 2016 21:50
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