HomeGenie Forum

Automation Program Plugins and Wizard Scripting => APP Contributions => Topic started by: mvdarend on June 01, 2015, 07:49:12 PM

Title: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on June 01, 2015, 07:49:12 PM
Buienradar (http://www.buienradar.nl/) is a Dutch language site which shows the current and expected rainfall for Belgium and the Netherlands.

They have a simple feed (http://gps.buienradar.nl/getrr.php?lat=52&lon=5.66) for retrieving expected rainfall for the coming two hours.

This is a first version of a Rainfall widget, so it's probably a bit buggy and the code definitely needs a clean up. But I wanted feedback about how to improve, any help will be greatly appreciated. :)

You can set the following parameters:

It outputs the following:

Place the files in the zip in the following folder: homegenie/html/pages/control/widgets/Arend/buienradar

Edit: 08-07-2015 uploaded latest versions of files.

Edit: 07-08-2015 uploaded new version with changes by Dani

Edit: 28-08-2015 New widget files (buienradar.zip) which shows Rain radar map when clicking on the widget.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on June 02, 2015, 06:52:37 AM
A few people downloaded this yesterday, but I accidently had uploaded the wrong widget files. You'll need to download the new .zip file for the correct version.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: KaZe on June 02, 2015, 12:21:07 PM
It's works for me. Thx
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on June 03, 2015, 08:49:53 AM
It's works for me. Thx
Thanks for the feedback KaZe.

I've noticed a couple of things that need work.

The feed usually has a start time of approx. 10 minutes earlier than the current time. The calculation in the current version is not very good, it doesn't look at the actual times but counts 5 minutes for every data point. For example if you retrieve the feed at 10:00 the start timeof the feed will most likely be 09:50, if rain is expected at 10:05 the value for RainExpected will be 15 instead of 5)

Graph could probably be more active, changing bar sizes depending on the maximum rain value expected.

Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: Peter1977 on June 04, 2015, 08:56:03 PM
great! i'll try it out tommorow

thanks!
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on June 05, 2015, 05:19:24 PM
I've uploaded a new version with the following changes:

- Threshold spelt properly... :-[
- Cleaned up the code a little
- Added more info to the widget (Max. rainfall expected).
- RainExpected and RainThresholdExpected now give the actual amount of minutes until rain is expected instead of a very badly calculated guess.

I've noticed that the feed will often give false rain values with a very low amount of rain expected. As far as I can see it is always below 0.05 mm per hour, so you can always set  the Threshold to that.

Here's a quick C# example for closing the Awning when rain is expected:

Code: [Select]
When.ModuleParameterChanged( (module, parameter) =>
                            {                             
                              if (module.Is("Buienradar"))
                              {         
                                if(parameter.Name == "Buienradar.RainThresholdExpected" && parameter.Value != "0")
                                {
                                  // Rain expected Close the Awning
                                  Modules.WithName("Awning").Off();
                                  return false;
                                }
                              }
                              return true;
                            });
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on June 13, 2015, 09:11:11 AM
I've uploaded a final(?) version with the following changes:

- Obsolete functions replaced with new ones (AddOption, UseWidget, Option)
- Rain graph fits in the widget better
- Max. rain expected info.
- Legend showing colors/rainfall info
- Tooltip when hovering over graph (was in previous version, but I forgot to mention it)
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on June 19, 2015, 07:33:17 PM
The error trapping isn't very good, sometimes when there is an error or empty data the APP crashes. I'm testing a new version at the moment, I'll upload it in a couple of days (if it proves to be more stable.)
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on June 22, 2015, 02:01:39 PM
New version with better error handling.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on July 08, 2015, 07:24:48 AM
Just uploaded another new version of the .hgx file, the previous one still crashed every now and again. This version has been running for over a week without issue.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: NicoVermeir on July 20, 2015, 12:18:00 PM
can't seem to get this to work. I copied the files from the zip into the right folder, it shows up in the widget section but I can't get it to appear in the add module dialog. how do I add this to a group?
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: dani on July 20, 2015, 01:11:49 PM
You have to put the widget zip files in the folder /usr/local/bin/homegenie/html/pages/control/widgets/Arend
For me in France that work.
Only I need to modify the line 50 by that code :
double RainThreshold = Program.Option("RainThreshold").DecimalValue;
Instead of I got Program Notify Error : CR Unknown And Red light for the program. I am running on Debian and Convert.ToDouble generate that error.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on July 20, 2015, 04:28:15 PM
can't seem to get this to work. I copied the files from the zip into the right folder, it shows up in the widget section but I can't get it to appear in the add module dialog. how do I add this to a group?
Does the imported .hgx file work, or are you seeing the same problem that Dani has?

If you can start the APP, and it gets a little green ball it should show up in the Add module dialog.

Dani, is it possible that you're running a different version of Mono? I'm running on a BananaPi, mono --version gives me this:
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4+rpi1)
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: dani on July 20, 2015, 10:02:11 PM
My mono version :
Mono JIT compiler version 4.0.1 (tarball Tue May 12 15:39:23 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com (http://www.mono-project.com)
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: NicoVermeir on July 20, 2015, 10:22:17 PM
can't seem to get this to work. I copied the files from the zip into the right folder, it shows up in the widget section but I can't get it to appear in the add module dialog. how do I add this to a group?
Does the imported .hgx file work, or are you seeing the same problem that Dani has?

If you can start the APP, and it gets a little green ball it should show up in the Add module dialog.

Dani, is it possible that you're running a different version of Mono? I'm running on a BananaPi, mono --version gives me this:
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4+rpi1)

I tried the hgx, didn't seem to do anything. I then copied the files from the zip into the folder, now the widget shows up but when I try to run / preview it I get "TypeError: Unable to get property 'Name' of undefined or null reference
Line 27, Column 5"
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on July 21, 2015, 08:19:43 AM
I've updated Mono to 4.0.2:
Mono JIT compiler version 4.0.2 (Stable 4.0.2.5/c99aa0c Wed Jun 24 10:33:52 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com (http://www.mono-project.com)

But I can't seem to reproduce the problem you're seeing Dani, compilation is giving me no errors.

NicoVermeir, the error you're getting is in the Widget Editor? I get the same error if I haven't set the 'bind to module', see image:

* Edit, Added second image with correct binding.
 
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: NicoVermeir on July 21, 2015, 10:21:07 AM
Edit: never mind, got it to work. I was trying to import the hgx as a widget but it's a program. I feel like a noob now :D

thx for the assist
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: dani on July 21, 2015, 04:13:46 PM
Hi MvdaRend,

It's not at the compilation that I get the error. The error is generated when I run the task. So if you call DecimalValue of the property, you get the same result than Convert.ToDouble
Just make new try and I get same issue.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on July 22, 2015, 08:30:25 AM
Nico: Thanks for the update, any feedback/improvements greatly appreciated.

Dani: I still can't reproduce the problem. Could it be that you're using commas (,) instead of points (.) in your values? I always use points, and hadn't thought to test for commas.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: dani on July 25, 2015, 07:13:54 AM
Hi mvdarend,

1 - First time today I have rain so you project doesn't work in France.
I got that line in the rawdata :
0,39|07:10,0,22|07:15,0,18|07:20,0,45|07:25,0,24|07:30,0,12|07:35,0,13|07:40,0,17|07:45,0,19|07:50,0,06|07:55,0|08:00,0|08:05,0|08:10,0|08:15,0|08:20,0|08:25,0|08:30,0|08:35,0|08:40,0|08:45,0|08:50,0|08:55,0|09:00,0|09:05,0|09:10
As you can see, the value has coma. So I think it will be better to separate the raw by ';'. If not the widget crash due to coma that you use at first to split the properties.
2 - You represent only the raw of :00 and :30 so it will be judicious to add the values for each half past time, for exemple XX:00 add XX:00 XX :05 XX:10 XX:15 XX:20 and XX:25.
Because now the rain is some mm for one hour and the graph don't show any barregraph.
3 - You don't display the current Half Hour.
4 - For now I have Max expected 0,45mm/hour and nothing in the graph. I think it's for 10 mns. So you have to multiply by 12.

I don't know exactly what value they send, but my feeling is that each value is for the next 5 mns, isn't it ? Regarding to the raining time I get now.

If you agree I make modification and I post it

Cheers
Dani
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on July 25, 2015, 08:38:50 AM
Thanks Dani, here are some replies I know the answer to:

1: Thanks, I'll have to either use a ; or force the using of a point instead of a comma iwhen calculating the real values from the data-feed.
2: There is a bar shown for every value given, but the widget only shows the time labels for to :00 and :30 times. (ie. in between these times the bars for other times should be shown, see example picture in first post)
3: That's strange, mine has always shown the current half hour, could you show a screenshot?
4: I'm not sure what you mean here, could you elaborate?

Quote
I don't know exactly what value they send..

Here are the exact values they send: (example given is for the default location)
http://gps.buienradar.nl/getrr.php?lat=52&lon=4 (http://gps.buienradar.nl/getrr.php?lat=52&lon=4)
here is some info:
http://gps.buienradar.nl/ (http://gps.buienradar.nl/)

Here is a translation of the most important part:
mm/per hour = 10^((value-109)/32)
eg. 77 = 0.1 mm/uur

Thanks for your feedback, any improvements you wish to make will be greatly appreciated.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: dani on July 25, 2015, 10:47:22 AM
Hello Mvdarend,
Thank's for your answers.
I will make more invertigation, but for now no rain here.

Cheers
Dani

Actually 11:20 for your coordinate I get that screen.
There are some values but no graph is shown.

PS : Now I got current time in the list. because I had (x ==0) test in .js file.
        if ( x == 0 || theTime.indexOf(':00') > 0 || theTime.indexOf(':30') > 0)  

Now I got graph display, I modify .js file :
        var theRain = data[0].replace(',', '.');

Only now the graph is not align with time.

Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on July 27, 2015, 07:46:36 AM
Thanks for the update Dani, I'll have to adjust and test it properly with commas instead of points in the values.

Could you try the following:

In the .hgx file replace the following: (ie, change the comma "," to a semicolon ";")
Code: [Select]
// RawDataForWidget is a slightly modified version of the original data
//RawDataForWidget += String.Format("{0}|{1},", mmPerHour, dataPoint[1]);
RawDataForWidget += String.Format("{0}|{1};", mmPerHour, dataPoint[1]); // this is the changed line
LoopNumber += 1;

And in the widget, the following:
Code: [Select]
          if (module.Properties[p].Name == 'Buienradar.RawData') {
            var maxValue = 0;
            // var lines = propValue.split(',');
            var lines = propValue.split(';');
            // create the graph


Oh, I misread your post, I see that you've got it working.
Yes, the bars are not perfectly aligned with the times. Depending on the start time of the feed they'll shift slightly. I haven't found a good way to make them line up perfectly yet, although I'm fairly happy with it as it is now as it gives a fairly good idea of what's to come.

Any ideas for getting them to line up perfectly?
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: dani on July 27, 2015, 06:25:16 PM
I will try by adding a minus sign behind the hour and after I will try to align the drawing.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: dani on July 30, 2015, 11:23:41 AM
Hi MvdArend,

I join here some improvments of your Widget :
HGX : Adding TimeSlice in the result string RawData to align with 30 mns scale.
Widget : Align Graph with time points.

Cheers
Dani
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on July 30, 2015, 11:27:06 AM
Thanks Dani, I'll try it out later on.

I see that you've added FR as supported country, I thought only NL and BE was supported. Does it work for all of France, or only the northern area?
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: dani on July 30, 2015, 11:07:51 PM
I don't know if it's work for all France. It's real, I stay north of France (Near Boulogne sur mer under Calais).
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on August 07, 2015, 09:01:08 AM
Thanks for the improvements Dani, I've updated the first post with your files.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on August 28, 2015, 08:47:02 AM
I've made the widget clickable, showing the Rain Radar map.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: bastienboutonnet on November 25, 2015, 05:07:11 PM
Hey. Looks like a fun app. I was thinking of designing one as a way to teach myself js actually.

I have two questions:
1. How do I install that on a mac os? All bits of info about installation do not seem to make sense to me
2. Is there a documentation on how gps.buienradar.nl's API works? Like how you get maybe other info like the current temperature and conditions? I assume maybe you already know? I emailed then 3 days ago but I have not heard anything back and I think I probably never will.
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on November 25, 2015, 07:51:45 PM
Hi there,

1: Do you mean installing HomeGenie or the Buienradar App?
 - For HomeGenie: http://genielabs.github.io/HomeGenie/install.html (http://genielabs.github.io/HomeGenie/install.html)
 - For the buienradar App, Import the Program (the .hgx file) and place the widget files in the correct folder (see the first post)

2: This is all the info I know of: http://gps.buienradar.nl/ (http://gps.buienradar.nl/)
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: bastienboutonnet on November 30, 2015, 06:27:36 PM
Gotcha! Only just realised that homegenie was an environmemt.

Regarding data, you only know of the feed where you give coordinates and it gives you the rain factor for the coming hours? No way to easily get the current conditions right?
Title: Re: Buienradar (Rain radar) for NL and BE users
Post by: mvdarend on November 30, 2015, 07:14:26 PM
Regarding data, you only know of the feed where you give coordinates and it gives you the rain factor for the coming hours? No way to easily get the current conditions right?
Not that I know of, no. But you could use the OpenWeatherData or Weather Underground apps for that.