updateWeatherSensors (yet another buienradar script)  [SOLVED]

Moderator: leecollings

Post Reply
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

updateWeatherSensors (yet another buienradar script)

Post by waaren »

Because of size limitations on this forum I can no longer post the script in text format. Please download the attached zip.

This script is based on various other scripts and plugins found on the Domoticz forum. I gracefully borrowed code and solutions from many contributors over here. It is by no means perfect or even complete. I hope that if you use it or get some ideas out of it, you will enjoy it as much as I had when writing it.
I welcome all constructive comments, improvements and ideas. New versions will be posted here Latest version 0.20190808

Detailed explanation and History can be found inside the leesmij.txt, script and setting file.

All settings are to be done in weatherSettings.lua
There should be no need to change something in updateWeatherSensors.lua

First rows in weatherSettings.lua are your weather devices as defined in domoticz identified by their device number

(Note: You only have to define the sensors / switches you want to use and can comment the other ones by typing
-- in front of the line )
If you already defined devices for previous versions of this script and you don't need them any longer
you can also comment them with the two -- in front an delete them in domoticz

Last but not least: Many thanks to dannybloe and others for dzVents.

History since last posting
======================
20180429 Added location retrieval from domoticz settings
20180430 Adjusted Lux calculation
20180430 Fixed bug in Barometer setting (wrong dz.constants) and
20180430 Add setting for significant decimals in barometer
20180501 Get domoticzurl from system no longer required to give IP / Port in setting
20180502 Add option to separate windchill from wind device
20180504 More adjustments to Lux calculation based on SolarPower (thanks to poudeness)
20180504 Add file with Curle errors (Will be loaded in debug mode only)
20180505 Set weatherstation is now optional. Script gets nearby weatherstation based on longitude / latitude from domoticz
20180505 Script will get home address based on longitude / latitude from domoticz
20180506 Script will dump json Returns to file on request, -significant errors and when dz.LOG_DEBUG is active.
20180506 Script will load data from files in test-mode
20180507 Add option to get data from other nearby stations when getting specific data from initial station failed
20180508 Moved local vars to tables.
20180510 Moved functions to separate file
20180511 Made load data from files in test mode and dump json Returns to file mutual exclusive
20180512 Loglevel now in settings
20181204 Add possibility to use google API key ( https://cloud.google.com/maps-platform/ ... t-changes/" ) for address resolution
20181205 Bugfix: use choice between domoticz location or weatherstation also for rainforecast.
20190808 Made script more resilient if dzVents does not recognize HTTP response as JSON ( forum link )
Attachments
WUS.zip
Setting-, function-, error- and Maincode file
version 20190808
(31.77 KiB) Downloaded 275 times
Last edited by waaren on Wednesday 05 December 2018 12:32, edited 33 times in total.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by schulpr »

Thank you! I like it very much. No problems anymore with different versions of Python that kill each other.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by EdwinK »

going to try this.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by waaren »

New version available; see first post here Latest version 0.20180413
Last edited by waaren on Friday 13 April 2018 23:43, edited 1 time in total.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by EdwinK »

You posted a link to edit your post. Good thing we can't use those.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by waaren »

Sorry about that. Should be OK now
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by schulpr »

@waaren what is changed compared with the previous version? Should I update?

Kind regards, Rob


Forget my question. I saw your comments in the script.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by waaren »

schulpr wrote: Saturday 14 April 2018 7:43 @waaren what is changed compared with the previous version? Should I update?

Kind regards, Rob
Hi schulpr,

couple of fixes, additions and improvements. (see below in History). I expect some more to come in the next couple of days / weeks.

todo
====
separate user specific settings from main file
user adjustable interval for logging to domoticz logfile
....


History
========
20180408 Start coding
20180411 First version active and shared on forum
20180412 Added check on text fields (do not overwrite same text)
20180413 Added more checks and logs
20180413 Corrected rain forecast formulas
20180413 Adjusted rain forecast devices
20180413 Added Alert,text and switch rain forecast devices (all optional)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by schulpr »

Hi @waaren,

Thanks for your reply.

I think you have to add some underscores in lines 139 en 140.

local rainForecast_1_hour
local rainForecast_2_hours

Regards, Rob
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by waaren »

Done,

and thx !
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by schulpr »

Hi @waaren,

I get this error: Error (2.4.4): WUS: : Multiple items found for Lang weerbericht (device). Please make sure your names are unique or use ids instead.

Any idea why?

Kind regards, Rob
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by waaren »

schulpr wrote: Sunday 15 April 2018 7:56 Hi @waaren,

I get this error: Error (2.4.4): WUS: : Multiple items found for Lang weerbericht (device). Please make sure your names are unique or use ids instead.

Any idea why?

Kind regards, Rob
this message is a standard message from dzVents if a devicename is not unique in your database. Can you change to the devicenumber of this device ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by schulpr »

I renamed the device and now it's working correct. Strange, I can't see the other device with the same name.

Thanks for the tip.

Rob
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by waaren »

Hi Rob,

it might be related with the problem I reported in another topic. Text devices with a string length > 240 are not shown in the devices or utility tab but are still present in the database.
Until this is fixed by the domoticz developers, I restrict the length of the long forecast text to max. 240 chars. New version will be available late tonight or tomorrow with this and other fixes / mods.

I will also report this as an issue at the domoticz github.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by waaren »

New version available; see first post here Latest version 0.20180416

User specific settings (including your devices) can now be separated from main code file. Both files in the attached zip


History
========
20180408 Start coding
20180411 First version active and shared on forum
20180412 Added check on text fields (do not overwrite same text)
20180413 Added more checks and logs
20180413 Corrected rain forecast formulas
20180413 Adjusted rain forecast devices
20180413 Added Alert,text and switch rain forecast devices (all optional)
20180414 User adjustable interval for Info logging to domoticz logfile
20180414 User adjustable interval for updating unchanged sensors/switches
20180414 Shortened long forecast string to 240 chars because of bug in domoticz
20180415 Separated user specific settings from main codefile
20180416 Improved layout text to logfile
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by EdwinK »

Thanks. I like settings to be separated so you don't have to add them time and time again.

Is it default that the alert tile and the alert txt give the same message? Shouldn't one text be enough?
Screen Shot 2018-04-16 at 14.49.57.png
Screen Shot 2018-04-16 at 14.49.57.png (38.47 KiB) Viewed 5573 times
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by waaren »

One choice should be enough but from the alert device you can also get the alert level.
Just pick the one you like and ignore the other one. eg comment one in the setting file
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by EdwinK »

waaren wrote: Monday 16 April 2018 19:04 One choice should be enough but from the alert device you can also get the alert level.
Just pick the one you like and ignore the other one. eg comment one in the setting file

Thanks. Thought so, but better to ask before killing thngs.
Last edited by EdwinK on Monday 16 April 2018 20:44, edited 1 time in total.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by schulpr »

@waaren I get a lot of log input. Most important: Info: WUS: no Uservars file available.

The file is the the correct folder. Any idea?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateWeatherSensors (yet another buienradar script)

Post by waaren »

schulpr wrote: Monday 16 April 2018 20:05 @waaren I get a lot of log input. Most important: Info: WUS: no Uservars file available.

The file is the the correct folder. Any idea?
Hi Rob,

thanks for testing. I do not really have an idea yet. I run domoticz as root so that might be a reason why I don't see the problem but I am not sure.

could it be an access rights problem ?
On what version of dzVents are you ?
Are you on the Synology or on PI ?
what OS ?
if you run with option debug in the script and on dzVents general level (setup -> settings -> other -> dzvents -> debug ) do you get more relevant info ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest