Page 1 of 8

updateWeatherSensors (yet another buienradar script)

Posted: Wednesday 11 April 2018 23:51
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 )

Re: updateWeatherSensors (yet another buienradar script)

Posted: Thursday 12 April 2018 18:38
by schulpr
Thank you! I like it very much. No problems anymore with different versions of Python that kill each other.

Re: updateWeatherSensors (yet another buienradar script)

Posted: Thursday 12 April 2018 20:24
by EdwinK
going to try this.

Re: updateWeatherSensors (yet another buienradar script)

Posted: Friday 13 April 2018 21:53
by waaren
New version available; see first post here Latest version 0.20180413

Re: updateWeatherSensors (yet another buienradar script)

Posted: Friday 13 April 2018 22:46
by EdwinK
You posted a link to edit your post. Good thing we can't use those.

Re: updateWeatherSensors (yet another buienradar script)

Posted: Friday 13 April 2018 23:44
by waaren
Sorry about that. Should be OK now

Re: updateWeatherSensors (yet another buienradar script)

Posted: Saturday 14 April 2018 7:43
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.

Re: updateWeatherSensors (yet another buienradar script)

Posted: Saturday 14 April 2018 9:43
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)

Re: updateWeatherSensors (yet another buienradar script)

Posted: Saturday 14 April 2018 12:12
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

Re: updateWeatherSensors (yet another buienradar script)

Posted: Saturday 14 April 2018 13:02
by waaren
Done,

and thx !

Re: updateWeatherSensors (yet another buienradar script)

Posted: Sunday 15 April 2018 7:56
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

Re: updateWeatherSensors (yet another buienradar script)

Posted: Sunday 15 April 2018 8:26
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 ?

Re: updateWeatherSensors (yet another buienradar script)

Posted: Sunday 15 April 2018 16:13
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

Re: updateWeatherSensors (yet another buienradar script)

Posted: Sunday 15 April 2018 19:06
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.

Re: updateWeatherSensors (yet another buienradar script)

Posted: Monday 16 April 2018 11:15
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

Re: updateWeatherSensors (yet another buienradar script)

Posted: Monday 16 April 2018 14:52
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 5619 times

Re: updateWeatherSensors (yet another buienradar script)

Posted: Monday 16 April 2018 19:04
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

Re: updateWeatherSensors (yet another buienradar script)

Posted: Monday 16 April 2018 19:14
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.

Re: updateWeatherSensors (yet another buienradar script)

Posted: Monday 16 April 2018 20:05
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?

Re: updateWeatherSensors (yet another buienradar script)

Posted: Monday 16 April 2018 20:36
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 ?