Buienradar Weather Lookup Plugin

Python and python framework
Post Reply
ffes
Posts: 51
Joined: Friday 27 January 2017 0:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: NL
Contact:

Buienradar Weather Lookup Plugin

Post by ffes » Wednesday 08 February 2017 23:11

Hi,

I put my first attempt to write a plugin for Domoticz on-line. It is a virtual weather station based on http://xml.buienradar.nl I have running on my installation at home for a couple of days now.

It can be found at https://github.com/ffes/domoticz-buienradar

At the moment after installing you need manually update your coordinates so the weather station nearby is automatically found. I hope there is a decent way to get this information from the Domoticz settings, but I have not found it yet.

Other then that it only works for the temperature at the moment. I need to figure out how I can generate some of the additional info you need to summit when for instance I add a humidity device.

Note that since it uses buienradar for weather information, it only works for location within (or close by) The Netherlands. Also note it only uses the xml feed of the weather information, not the rain images we all are so familiar with from buienradar.

Update 19-Feb-2017:
All relevant weather information (temperature, humitidy, barometer and wind) can be viewed.
Last edited by ffes on Sunday 19 February 2017 18:50, edited 1 time in total.

User avatar
G3rard
Posts: 825
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.8153
Location: The Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by G3rard » Thursday 09 February 2017 0:02

Nice! Will certainly try this plugin.
You could also use the xml part of the script to add fields for lat and lon which the user can enter in the hardware page in stead of the script. But indeed even better to reuse the settings from Domoticz.
Ubuntu Server 14.04 | Domoticz v3.8153 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos PHP | Dark th3me | Sony Bravia Python plugin | Sonos Python plugin

User avatar
remb0
Posts: 811
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by remb0 » Thursday 09 February 2017 20:28

wow nice! buienradar is easier and at my adress more accurate.
I hope rain will included in the future :)

ffes
Posts: 51
Joined: Friday 27 January 2017 0:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes » Thursday 09 February 2017 23:54

Thanks guys to the positive feedback!

I just updated the repository on github. Now the user must fill in the latitude and longitude on the hardware page in the interface as suggested by G3rard. So you no longer need to manually edit the script :)

User avatar
G3rard
Posts: 825
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.8153
Location: The Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by G3rard » Friday 10 February 2017 1:55

I get this error after the update.

Code: Select all

2017-02-10 00:48:18.650 Error: (Buienradar) 'onStart' failed 'ValueError':'could not convert string to float: '.
2017-02-10 00:48:18.650 Error: (Buienradar) ----> Line 44 in /home/gerard/domoticz/plugins/domoticz-buienradar/plugin.py, function onStart
I entered some dummy lat lon data in the XML and restarted Domoticz, but that gives the same error.

After entering the lat lon in the hardware page, all works fine.

Code: Select all

2017-02-10 00:55:40.127 (Buienradar) Initialized version 1.0, author 'ffes'
2017-02-10 00:55:40.127 (Buienradar) Retrieve weather data from http://xml.buienradar.nl/
2017-02-10 00:55:40.213 (Buienradar) Found Meetstation Lelystad at 30.0 km from your home location
2017-02-10 00:55:40.213 (Buienradar) Temperature: -4.3
2017-02-10 00:55:40.213 (Buienradar) Wind Speed: 3.03
2017-02-10 00:55:40.213 (Buienradar) Wind Direction: 57.0
2017-02-10 00:55:40.213 (Buienradar) Wind Speed Gusts: 4.2
Maybe you can also add the wind devices?

Regarding getting the data from Domoticz, I just found that http://192.168.1.170:8080/json.htm?type ... =getconfig gives you the lat lon from Domoticz.
Don't know if you can use that in the Python script, but maybe it can help you.
Ubuntu Server 14.04 | Domoticz v3.8153 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos PHP | Dark th3me | Sony Bravia Python plugin | Sonos Python plugin

schulpr
Posts: 80
Joined: Thursday 01 January 2015 10:10
Target OS: NAS (Synology & others)
Domoticz version: Beta
Contact:

Re: Buienradar Weather Lookup Plugin

Post by schulpr » Friday 10 February 2017 9:30

Hello,

I really love this development. No more api calls with restrictions, etc.

I live in Lelystad. (lat: 52.50, lon: 5.49). I believe we have a weather station nearby. However, I get this message in the log: Found Meetstation Lopik-Cabauw at 11.8 km from your home location. I Think Lopik is a bit further away ;).

Please keep up the good work and I hope you will add the other information too for use on the dashboard.

Rob

ffes
Posts: 51
Joined: Friday 27 January 2017 0:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes » Friday 10 February 2017 10:28

@G3rard
I had the similar problems with upgrading my script. Don't know why the default value didn't work. But entering it on the hardware page solves that indeed.

I will look at the web API way to get the coordinates. Feels really odd that a Python hardware plugin is able to create devices and set values, but to get some settings you need to use the web API. Then I still need to ask the use for hostname/ip, port and maybe even user/password. This is more then copying two numbers.

I will have to figure out how to calculate the wind chill temperatures when creating a wind device. According to https://www.domoticz.com/wiki/Domoticz_ ... URL's#Wind that needs to be one of the values in the sValue. I think I found the right formula on https://nl.wikipedia.org/wiki/Gevoelstemperatuur so hopefully this weekend I have some time to look at this a bit further (busy weekend ahead :) )

ffes
Posts: 51
Joined: Friday 27 January 2017 0:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes » Friday 10 February 2017 10:30

@schulpr

I will test with your coordinates and see why Lelystad is not selected as your nearby station

ffes
Posts: 51
Joined: Friday 27 January 2017 0:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes » Friday 10 February 2017 14:30

@schulpr

I took a quick peek. It turns out buienradar changed (or better messed up) their xml format. The fields "latGarden" + "lonGraden" (used to be coordinates in decimal notation) are swapped with "lat" + "lon" (used to be coordinates in minutes notation).

But even worst... Take a look at the coords of for instance "Arnhem":

Code: Select all

<weerstation id="6275">
  <stationcode>6275</stationcode>
  <stationnaam regio="Arnhem">Meetstation Arnhem</stationnaam>
  <lat>52.07</lat>
  <lon>5.88</lon>
  <datum>02-10-2017 12:40:00</datum>
  <luchtvochtigheid>84</luchtvochtigheid>
  <temperatuurGC>-2.1</temperatuurGC>
  <windsnelheidMS>4.02</windsnelheidMS>
  <windsnelheidBF>3</windsnelheidBF>
  <windrichtingGR>64</windrichtingGR>
  <windrichting>ONO</windrichting>
  <luchtdruk>1023.42</luchtdruk>
  <zichtmeters>3900</zichtmeters>
  <windstotenMS>5.8</windstotenMS>
  <regenMMPU>-</regenMMPU>
  <zonintensiteitWM2>81</zonintensiteitWM2>
  <icoonactueel ID="p" zin="half bewolkt">http://xml.buienradar.nl/icons/p.gif</icoonactueel>
  <temperatuur10cm>-2</temperatuur10cm>
  <url>http://www.buienradar.nl/nederland/weerbericht/weergrafieken/6275</url>
  <latGraden>52.11</latGraden>
  <lonGraden>6.47</lonGraden>
</weerstation>
Notice the big difference between "lon" and "lonGraden"!!! 6.47 vs 5.88. The number in before the dot should always be the same.

I also noticed that they changed the formatting in the "datum" field, but that is no big deal for me. I ignore this field.

In my localtest I used the "lat" and "lon" fields and then "Meetstation Lelystad" is selected at 6.2 km from your location.

Not sure what the best fix is. I asked buienradar this question on their contact form, but don't expect too much from that (but maybe I an too negative). We will see.

schulpr
Posts: 80
Joined: Thursday 01 January 2015 10:10
Target OS: NAS (Synology & others)
Domoticz version: Beta
Contact:

Re: Buienradar Weather Lookup Plugin

Post by schulpr » Friday 10 February 2017 15:14

Hi ffes,

Thanks for your findings. For now I changed my settings to the numbers Buienradar is using. That's <latGraden>52.75</latGraden>
<lonGraden>5.89</lonGraden> for me in Lelystad. I will change this if you make adjustments to your great plugin.

Best regards,

Rob

User avatar
Brutus
Posts: 283
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Heerlen, The Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Brutus » Saturday 11 February 2017 0:38

This sounds nice. It also works under Windows ;)

It only selects the nearest Weather station 53km away. But that's a know issue now.
1x Intel NUC D54250WYK (Windows 7)
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
17x Fibaro Modules

ffes
Posts: 51
Joined: Friday 27 January 2017 0:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes » Monday 13 February 2017 14:07

I just pushed a new version to the github repository. When you pull in the new version the plugin will now use the fields <lat> and <lon> of the weather station. So make sure you use the right coordinates on the hardware page.

Other then that I am working on adding a wind device. It mostly works, but I need to figure what the best way is to upgrade, because a new device will be added. Probably just documenting how it should be done will enough right now.

EldigoR
Posts: 20
Joined: Monday 12 October 2015 19:57
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Buienradar Weather Lookup Plugin

Post by EldigoR » Monday 13 February 2017 14:34

nice work!. Nicely picks a weatherstation nearby :)

Code: Select all

2017-02-13 13:20:33.613 (Buienradar Weather) Devices created.
2017-02-13 13:20:33.613 (Buienradar Weather) Retrieve weather data from http://xml.buienradar.nl/
2017-02-13 13:20:33.664 (Buienradar Weather) Found Meetstation Rotterdam at 6.3 km from your home location
2017-02-13 13:20:33.664 (Buienradar Weather) Temperature: 4.2
2017-02-13 13:20:33.664 (Buienradar Weather) Wind Speed: 6.8
2017-02-13 13:20:33.664 (Buienradar Weather) Wind Direction: 85.0
2017-02-13 13:20:33.664 (Buienradar Weather) Wind Speed Gusts: 9.7
Looking forward to the wind device.

Are you also planning to use the other data available?

Code: Select all

<luchtvochtigheid>
<luchtdruk>
<zichtmeters>
<regenMMPU>
<zonintensiteitWM2>

ffes
Posts: 51
Joined: Friday 27 January 2017 0:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes » Monday 13 February 2017 14:55

@EldigoR

Yes, I am. But there are some things I need to dig in to. As I mention in my original post, how do I fill the extra parameters that are needed when you create those devices? I am a dev, don't know very little about meteorology.

schulpr
Posts: 80
Joined: Thursday 01 January 2015 10:10
Target OS: NAS (Synology & others)
Domoticz version: Beta
Contact:

Re: Buienradar Weather Lookup Plugin

Post by schulpr » Monday 13 February 2017 19:53

Hi ffes,

I removed the old plugin and try to install the new version but it isn't visible anymore under "Hardware".

Did I do something wrong?

Kind regards, Rob

ffes
Posts: 51
Joined: Friday 27 January 2017 0:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes » Monday 13 February 2017 22:13

Just ran into the same problem. Not sure what broke it, but these lines in the log must have something to do with it:

Code: Select all

2017-02-13 21:06:21.568 PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.
2017-02-13 21:06:21.570 PluginSystem: 'Weer' Registration ignored, Plugins are not enabled. 
All I did was update to the latest beta a couple of minutes before. Not sure how to rollback to the version I was on this morning when it still worked. But hey, these are the joys of using the beta release ;)

EldigoR
Posts: 20
Joined: Monday 12 October 2015 19:57
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: RE: Re: Buienradar Weather Lookup Plugin

Post by EldigoR » Monday 13 February 2017 23:46

ffes wrote:@EldigoR

Yes, I am. But there are some things I need to dig in to. As I mention in my original post, how do I fill the extra parameters that are needed when you create those devices? I am a dev, don't know very little about meteorology.
The anwser should be here I thank...
http://www.domoticz.com/wiki/Developing_a_Python_plugin

The device has be of the right typename. For example "Temp+Hum+Baro"

Then set the proper sValue :
TEMP;HUM;HUM_STAT;BAR;BAR_FOR

TEMP = Temperature
HUM = Humidity
HUM_STAT = Humidity status
BAR = Barometric pressure
BAR_FOR = Barometer forecast

https://www.domoticz.com/wiki/Domoticz_ ... Fbarometer


Verstuurd vanaf mijn D5803 met Tapatalk

ffes
Posts: 51
Joined: Friday 27 January 2017 0:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes » Tuesday 14 February 2017 0:23

Yes I know. But what are the right values for HUM_STAT and BAR_FOR?

How do I convert a percentage of humidity to a feeling (HUM_STAT). I found a table somewhere in the Internet. So I say < 45 = Dry, > 70 = Wet, everything else = comfortable. But are these are correct? I don't know.

How do I convert a air pressure in hPa to a prediction (BAR_FOR). I have looked some pictures of analogue barometers in the internet and I think I have some that should return a prediction. But again, if that is correct, I'm not sure.

I have just push that (weather) code, but haven't been able to add the devices yet. First my installation has to work again.

EldigoR
Posts: 20
Joined: Monday 12 October 2015 19:57
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Buienradar Weather Lookup Plugin

Post by EldigoR » Tuesday 14 February 2017 0:50

Just use the values you seem best, you have to have a degree in weather :)
It can be ajusted afterwards.

Verstuurd vanaf mijn D5803 met Tapatalk

EldigoR
Posts: 20
Joined: Monday 12 October 2015 19:57
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Buienradar Weather Lookup Plugin

Post by EldigoR » Tuesday 14 February 2017 0:56

def Windchill(T, W):
# T Enter the temperature
# W = wind speed m/s
Wkm = W * 3.6 # m/s -> km/uur
windchill= 13.12 + (0.6215*T) + (0.3965*(T - 28.676)*(Wkm**0.16))
return windchill


Might help for the wind Chill..

Verstuurd vanaf mijn D5803 met Tapatalk

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests