Buienradar Weather Lookup Plugin

Python and python framework

Moderator: leecollings

ffes
Posts: 51
Joined: Thursday 26 January 2017 23:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes »

I did play a bit on how to separate the devices. It is a bit of work, but certainly doable.

I need to find a reliable way to determine if a device is "temperature" or "temp+hum+baro". I think I have to examine the sValue for that because the TypeName is only used when creating a device and can not read from like "Devices[1].TypeName".

But for now, it becoming too late. Tomorrow will be another busy day at the office.
User avatar
Brutus
Posts: 249
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Brutus »

ffes wrote:I did play a bit on how to separate the devices. It is a bit of work, but certainly doable.

I need to find a reliable way to determine if a device is "temperature" or "temp+hum+baro". I think I have to examine the sValue for that because the TypeName is only used when creating a device and can not read from like "Devices[1].TypeName".

But for now, it becoming too late. Tomorrow will be another busy day at the office.
Sounds nice! Thnx for the time and work you put in this plugin!
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
Snowtiger
Posts: 120
Joined: Tuesday 18 October 2016 13:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10915
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Snowtiger »

ffes wrote:I did play a bit on how to separate the devices. It is a bit of work, but certainly doable.

I need to find a reliable way to determine if a device is "temperature" or "temp+hum+baro". I think I have to examine the sValue for that because the TypeName is only used when creating a device and can not read from like "Devices[1].TypeName".

But for now, it becoming too late. Tomorrow will be another busy day at the office.
I think maybe some info is present in this Python sub forum thread - viewtopic.php?t=15535
This plugin is working out well, great work :)
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Dnpwwo »

@ffes,

Maybe you could allow users to choose whether they want separate or combined devices via a drop down in the Hardware page?
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
Brutus
Posts: 249
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Brutus »

Dnpwwo wrote:@ffes,

Maybe you could allow users to choose whether they want separate or combined devices via a drop down in the Hardware page?
If that's possible you serve everyone I think ;)
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
ffes
Posts: 51
Joined: Thursday 26 January 2017 23:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes »

Dnpwwo wrote:Maybe you could allow users to choose whether they want separate or combined devices via a drop down in the Hardware page?
Yep, that is the plan.

But it is impossible to get the TypeName, to determine if I need to (re)create devices when the user updates his/her choice on the hardware page. I took a look at the code and assume it is only one extra line to CDevice_members[] (PluginManager.cpp L860). For me getting a magic number is fine at the moment. Not that much of a Python guy to know if and how consts in Python work (let alone how to add consts in the plugin manager).

The forum thread @snowtiger is mentioning is only about setting the type as a "TypeName" instead of a magic number field "Type" during creating.
EldigoR
Posts: 41
Joined: Monday 12 October 2015 19:57
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by EldigoR »

ffes wrote:I would make my life more difficult because the combined temp+hum+baro wants other values for BAR_FOR then the plain Barometer device: https://www.domoticz.com/wiki/Domoticz_ ... #Barometer
Did some searching regarding the Barometer forecast but to really forecast the weather, you will need pressure history. So I wouldn’t bother with that, keep things simple as you do now and use the "temp+hum+baro" device ;)
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Dnpwwo »

@ffes,

There are a couple of ways to handle the device types.

For some of the plugins I've done I took an approach of simply creating all possible devices on startup if (len(Devices) == 0). As long as your code then checks a Device exists before updating it (which yours does because use are using the UpdateDevice helper function) then people can delete the ones they don't want. As long as they don't delete them all the extra ones won't be recreated.

Alternatively just give the devices different Unit numbers. Say, Unit 1 for combined and units 2,3 & 4 for the separate ones. That way you can check at startup that the units exist that match the parameter and take the corrective answer if not.

Out of the 2 I personally prefer the first.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Snowtiger
Posts: 120
Joined: Tuesday 18 October 2016 13:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10915
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Snowtiger »

If you are using MQTT - do not update to latest beta available Version: V3.6722 yet - Domoticz will fail - see Bugs topic in forum
ffes
Posts: 51
Joined: Thursday 26 January 2017 23:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes »

This is what I am going to do:

I will add two settings to the hardware page:
  • Combined temperature and humidity [Yes/no]
  • Add Wind chill to wind device [Yes/No]
And I will add a separate barometer device. Combining the barometer only has disadvantages. It is shown separately in the interface anyway, but when you combine the three and mark the temp/hum as favorite, the barometer will show in you dashboard as well.

When you do not combine the temperature and humidity, you will get two separate device. Know that temperature and humidity have a direct link. A colleague explained the psychics behind this a bit.

When you do not add the wind chill you will not see this information at all. There is no "apparent temperature" device in domoticz.

Know that the apparent temperature is not the same as Wind Chill. Wind Chill is only calculated for temps < 10C. For higher temperatures you need to take the humidity into account. It is called the "heat index", but that is only calculated for temps > 27C, so not too common in NL ;)
https://en.wikipedia.org/wiki/Apparent_temperature
https://en.wikipedia.org/wiki/Heat_index
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Buienradar Weather Lookup Plugin

Post by schulpr »

Hi ffes,

I changed line 58 in plugin.py from 15 to 10, restarted Domoticz, but the refresh rate is still 15 minutes. Do I need to change or do something else to change it?

Kind regards, Rob
Snowtiger
Posts: 120
Joined: Tuesday 18 October 2016 13:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10915
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Snowtiger »

sander815 wrote:i deleted the plugin in hardware, redownloaded it from git, but now i cannot add it anymore. I can select it, but the add button does nothing?
did you restart Domoticz? This will help some times ;)
Henk50
Posts: 7
Joined: Saturday 18 February 2017 9:34
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Henk50 »

Today I installed Buienradar on the latest beta V3.6749.
Buienradar is in the hardware, but after configuring in de log will come the error:
2017-02-19 12:37:53.738 Error: (Buienradar) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/domoticz-buienradar/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2017-02-19 12:37:53.738 Error: (Buienradar-VDaal) Module Import failed, exception: 'SyntaxError'
2017-02-19 12:37:53.738 Error: (Buienradar-VDaal) Import detail: File: /home/pi/domoticz/plugins/domoticz-buienradar/buienradar.py, Line: 1908899872, offset: 293
2017-02-19 12:37:53.738 Error: (Buienradar-VDaal) Error Line ' if self.humidity >= 35 and self.humidity =< 65:
'
Looks to be a syntax error? How can I fix this?
Arduinomn
Posts: 1
Joined: Sunday 19 February 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Arduinomn »

Edit the file, change
self.humidity =< 65:
Into
self.humidity <= 65:
ffes
Posts: 51
Joined: Thursday 26 January 2017 23:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes »

This bug has been fix the repository earlier today.
https://github.com/ffes/domoticz-buienr ... bb470d6d0e

At the moment I am working on "selecting the combined devices or not". Still some minor hiccups in the code, but I getting there.
Henk50
Posts: 7
Joined: Saturday 18 February 2017 9:34
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Henk50 »

Install the plugin again and it's working now. Thnx!
Maybe you can add in the documentation that you also have to install python3-dev? Thanx for this in previous post.
ffes
Posts: 51
Joined: Thursday 26 January 2017 23:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes »

I just updated the repository. At the moment the plugin is quite complete. Temperature, humidity and barometer devices are supported.

To update an existing installation know that you need to restart Domoticz and remove all the devices and restart again, so the new devices can be added matching your preferences. Unfortunately you will loose the history of those devices.

I think I will need to contribute to the python plugin manager to get some of the features that I would love to have for this plugin to work ever more easily, like getting the location (lat,lon) from Domoticz instead of asking the user for duplicate information.
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Buienradar Weather Lookup Plugin

Post by schulpr »

Hi ffes,

Works great! Thank you very much for all the work you put into this.

Kind regards, Rob

Edit: A bit to quick in my response:

2017-02-19 17:58:29.018 Error: (Buienradar) 'onStart' failed 'TypeError':'type NoneType doesn't define __round__ method'.
2017-02-19 17:58:29.018 Error: (Buienradar) ----> Line 79 in /home/pi/domoticz/plugins/domoticz-buienradar/plugin.py, function onStart
2017-02-19 17:58:29.018 Error: (Buienradar) ----> Line 186 in /home/pi/domoticz/plugins/domoticz-buienradar/plugin.py, function fillDevices

Little bug?
ffes
Posts: 51
Joined: Thursday 26 January 2017 23:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Buienradar Weather Lookup Plugin

Post by ffes »

Works for me. That line is setting the barometer.

What is the weather station that is selected for your location?
Is there a barometer value in the logs from that station?

Only now see that not all the stations have a value for <luchtdruk> :-?
Henk50
Posts: 7
Joined: Saturday 18 February 2017 9:34
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Buienradar Weather Lookup Plugin

Post by Henk50 »

hi ffes,
Delete hardware in domoticz-hardware, delete buienradar directory in plugins and install again. Restart domoticz and add hardware.
Works perfect:
2017-02-19 19:09:01.646 (Buienr-VDaal) Initialized version 1.0, author 'ffes'
2017-02-19 19:09:01.699 (Buienr-VDaal) Retrieve weather data from http://xml.buienradar.nl/
2017-02-19 19:09:01.823 (Buienr-VDaal) Found Meetstation Arnhem at 23.0 km from your home location
2017-02-19 19:09:01.824 (Buienr-VDaal) Temperature: 5.0
2017-02-19 19:09:01.824 (Buienr-VDaal) Wind Speed: 2.72
2017-02-19 19:09:01.824 (Buienr-VDaal) Wind Bearing: 231.0
2017-02-19 19:09:01.824 (Buienr-VDaal) Wind Direction: SW
2017-02-19 19:09:01.824 (Buienr-VDaal) Wind Speed Gusts: 3.7
2017-02-19 19:09:01.824 (Buienr-VDaal) Wind Chill: 2.7
2017-02-19 19:09:01.825 (Buienr-VDaal) Barometer: 1020.44
2017-02-19 19:09:01.825 (Buienr-VDaal) Barometer Forecast: 0
2017-02-19 19:09:01.825 (Buienr-VDaal) Humidity: 98
2017-02-19 19:09:01.825 (Buienr-VDaal) Humidity status: 3
Many thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests