X10 Community Forum

📱🖥️PiX10Hub => 💬General Discussion => 📝User created HG Scripts (programs/macros/widgets) => Topic started by: Tuicemen on March 27, 2019, 09:49:51 AM

Title: 🌪️Weather Alerter for HG
Post by: Tuicemen on March 27, 2019, 09:49:51 AM
I use wind and temperature triggers a lot! (both greater then and less then values)
I know many have or would like rain or lack of triggered events scheduled too.
I'm currently playing with adding options for each module in HG for less then and greater then values for wind, rain and temperature, using the newly added OpenWeatherMap program Gene added to HG.
However I'm wondering if other weather events should also be included, like presure and humidity ???
I'm thinking turning the module on when greater or less then value is reached and back off when the value nolonger applies or maybe off after selected time in seconds.
Currently users can do this with a script but this will simplify things if do able and not over taxing the RPi CPU.
I'll post the HG app/program here once I have something usable. ;)
However I would like to read users ideas  on this.

Remove the txt extention from the WeatherAlerter file and install in the weathe rand environment programs section
remove the txt extention from the tuicemen_tools_info file then install in the widget section (don't unzip prior)
Title: Re: 🌪️Weather Alerter for HG
Post by: LostDog88 on March 27, 2019, 10:50:53 AM
Triggers for humidity would rock.

Fans under my house to keep it dry during humid months? Yes! Sign me up! LOL.

Air Dryers in my RV's that pop on when it is raining? Oh yah!

Home Automation. Love it! More than just turning off lights with a remote! LOL
Title: 🌪️Weather Alerter for HG
Post by: Tuicemen on March 27, 2019, 11:11:25 AM
I had thought there was a humidity value in the OPenWeatherMap but currently that is lacking.
I've requested that enhancement which would allow me to add humidity.
I think I can create a sever weather warning based off rapid pressure changes too so once I have the basics down I'll look into playing with that.
Title: RE:🌪️Weather Alerter for HG
Post by: bkenobi on March 27, 2019, 04:43:42 PM
Remember to include a hysteresis in your code.  If you don't you will create a constantly toggling module when the temp (or whatever) hovers at the trigger point.
Title: 🌪️Weather Alerter for HG
Post by: Tuicemen on March 28, 2019, 04:04:32 PM
Ya I had thought of that but no where near coding triggering yet.
Thanks for the tip!

I decided I wanted a widget to display Alert info for this.
Exactly what info it will finally display remains to be seen. I wasn't exactly sure if creating the display would stop options from being selectible in other widget devices but I discovered it doesn't. :)%
I also managed to add code to the OpenWeatherMap program to fetch the Humidity. Since OpenWeatherMap currently Doesn't display Humidity or a Barometer I tested these in the Weather Alert widget with success! :)%
Title: 🌪️Weather Alerter for HG
Post by: Tuicemen on March 31, 2019, 08:26:34 AM
I've got the widget scrolling through Wind, Rain, Humidity, Temperature and Barometer values  and updating the correct values as well as displaying a Icon and info. I setup the Barometer to display what the values indicate Dry, Very Dry, Rain, Stormy and Changing as well as the trend but that may take some time to debug. :(
I'll start coding module triggering in a day or two. ;)

Barometer trend I do have working though not as well as I would like so I may remove that part.
It does display updated status of all weather sensors available with the OpenWeatherMap if it is active.
Note: snow/rain conditions only display if conditions are right for it (temperature)
I started  coding for the condition module triggering and do have code added and working for temperature and wind values :)%
Humidity is next on my list followed by rain and snow.

Title: 🌪️Weather Alerter for HG
Post by: Tuicemen on March 31, 2019, 10:34:56 PM
UpDate: code is 90-95% done (is it ever realy done) ::) :' So I'm ready to get some user input with some ideas for extra options.
Currently any Sensor,Switch,Light,Dimmer,Siren can be triggered  ON or OFF by Temperature,Wind,Rain,Snow,Presure, or Humidity values that are >or< the set value. These options show up in the module settings under "Weather Alerter"
The widget displays Temperature, Wind, Rain, Snow, Presure, Conditions, & Humidity values & alerts. Of coarse you don't need to display the widget to use the weather triggers but it must be activated.

The OpenWeatherMap Program is required to pull the values, this was included in HG 1.2-stable.39 but required a patch  to display correctly. ver1.3-beta.2 fixed those issues. However humidity and imperial values are not yet included in the OpenWeatherMap HG program included in HG. I do have a patched OpenweatherMap program to allow humidity and fixes the display issues in version1.2-stable.39
For the 3 users that think they can use this, and if you wish to test run it, please PM or email me and I'll get you setup. >!
Title: Re: 🌪️Weather Alerter for HG
Post by: Tuicemen on April 02, 2019, 07:02:15 PM
With the increase in sever storm events and that season already upon us I would have thought there would have been a bit more interest in an app like this. ::) :' True your relying on the cloud using this widget but it can be easily converted to work with a weather station. I would have done or included it this way only my weather station bit the dust. :(
The OpenWeatherMap App pull interval is set at a default of every 30 mins  :o this is ridiculously long to be of any real value as a warning system. However with a little modification you can have this check every min. Much better but OpenWeatherMap.org only updates the data about every 5 mins :(   
Still a five min warning may be enough and is certainly better then nothing.

Testing all the possible weather conditions and triggers can take a long time for one person and since my location is relatively calm right now it will be a month or more before I'll feel comfortable posting the app. :(
 I added a wind direction indicator to the display today while playing with update intervals as this is now more a program then a simple script. ::) :'
Title: Re: 🌪️Weather Alerter for HG
Post by: LostDog88 on April 03, 2019, 09:21:51 AM
I have been watching this thread (I am usually a lurker anyways unless I can't figure it out myself). Sadly I have not had the time to test any of your upgrades. Maybe this weekend?

Had to rebuild chicken coops, boat carbs, garage door broke, camera installs, work life. Etc.

Thanks for what you do though, it is appreciated.
Title: Re: 🌪️Weather Alerter for HG
Post by: Tuicemen on April 12, 2019, 10:04:17 PM
I decided it would be better if all info is displayed at once instead of cycling threw the info.
this meant I needed to try my hand at creating a new widget.
I had started to do this for the HG tools and figured a simular widget could be created for the Weather Alerter.
here's what I got so far:
Title: 🌪️Sever Weather Alerts
Post by: Tuicemen on April 13, 2019, 06:01:53 PM
I've started to play with adding a Custom Sever Weather Alert. This will be triggered if both Wind speed rises above users inputted value as well as the Barometer falling below the users inputted value.
This will be independent of triggering devices.
Title: Re: 🌪️Weather Alerter for HG
Post by: bkenobi on April 15, 2019, 12:31:07 AM
It's fun creating your own code, but I'm curious if it wouldn't be easier to just add humidity etc to the existing weather apps/widgets?  You can create another app for the severe weather triggers, but since the source of your data appears to be the same as the default widgets expanding existing code makes sense.

Another thing to keep in mind I'd localization of the data.  If you are trying to use a weather app that isn't local enough, you may trigger or miss triggers.  I have been planning on similar types of triggers for years, but mine will be based on my PWS sensors rather than open source.  I want to make sure that I am looking at the exact data rather than what someone else (another user's PWS) is providing without knowing how they came up with it.
Title: Re: 🌪️Weather Alerter for HG
Post by: Tuicemen on April 15, 2019, 02:23:17 AM
This could have been made to read a csv file which is what many PWS softwares create and what my weather watch program used. Heck it still could if one wished to modify it.
Modifiying a program which is included in HG (hard coded) usually gets overwritten on an Update that's why I only added things like humidity to OpenWeatherMap. HG is designed to use it, so it is conceivable the next update will include the missing values.
This little project was/is designed for users with out a PWS and uses information HG gathers from OpenWeatherMap which replaces Weather Underground.
OpenWeaterMap can be used with a PSW so it may be possible to link your PSW that way, I've not looked into that option. However using ones PSW info directly instead would be a much faster and more reliable way of getting readings.
Title: Re: 🌪️Weather Alerter for HG
Post by: bkenobi on April 15, 2019, 11:17:39 AM
If you export the app and then import it, it won't be linked to the built-in app.  As a result, you can modify things all you want and it won't be overwritten.
Title: Re: 🌪️Weather Alerter for HG
Post by: Tuicemen on April 15, 2019, 12:09:47 PM
If you export the app and then import it, it won't be linked to the built-in app.  As a result, you can modify things all you want and it won't be overwritten.
True, I did that for a few things including OpenWeatherMap, and the Philips Hue.

There were a few reasons for creating the viewable widget, all personal.
1: to compare values and to be sure things (triggering & alerts) actually worked during coding.
2: to learn more how widgets and devices interact in HG.
3: to learn about building a new widget or modifying an existing one.(OpenWeatherMap widget I felt was to big of a task for me to bite off right now)
4: Finally I enjoy testing new updates and reporting issues it is what keeps a project moving forward. If I'm running a customized widget I get confused  as to what is working or not. rofl

The Weather Alerter app doesn't need to be displaying in order for the weather device triggering or SeverWeather E-mail Alert to work, it is just a bonus which some may enjoy.

I suppose if you got right down to it if I were to just modify an existing app I wouldn't need to make a separate sever weather alert app as it could be included in the modified app. ::)
Taking on this project helped me learn a lot about the inner workings of HG which I've only been running for slightly over a year.

Title: Re: 🌪️Weather Alerter for HG
Post by: Tuicemen on April 15, 2019, 09:54:32 PM
I had hoped HG build 1.3-stable.3 would have addressed some of the issues with the OpenWeatherMap program which this uses. Unfortunately this didn't happen B:(
Although I feel this (Weather Alerter) is more then ready for releasing  those wishing humidity alerts or Fahrenheit symbols (F) in the Open weather Map are out of luck unless they wish to edit some code.
This isn't a big deal for either the widget or program (takes less then 2mins and is documented on my forum) but I understand users not wishing to do this.  ;)

I've added code so the Weather Alerter will do the conversions and display correct values for those that want this in the Weather Alerter widget until OpenWeatherMap is working correctly in HG.
I've had some active weather the last few days and this has performed well for me with the options I had enabled.
I continue to fine tune things here with this for my setup and as I think of things which I may need either here or at my off grid place I add the options.
I have some hysteresis built in to the code but these I feel may need a bit more fine tuning ::) :'
Title: Re: 🌪️Weather Alerter for HG
Post by: Tuicemen on April 16, 2019, 08:29:24 PM
Currently I have a RC build of this posted on my forum and free to any user that has access to the members only section. http://forums.tuicemen.net/index.php?topic=1337.msg8297#msg8297
I would ask if you download it to play with that you post some feed back in that thread so I can weed out issues one may encounter. >!
Title: Re: 🌪️Weather Alerter for HG
Post by: soxfan1966 on April 17, 2019, 06:28:17 AM
Just wanted to chime in and say I agree with Tuicemen. 

While there can be advantages to copying existing code that often is better served once you understand it.  So starting something new (which can be based on something existing) allows me to get a better understanding of what the code is doing too. 

I think it's all a matter of what you are trying to achieve as well - getting something together quick to work vs getting something together that you understand how and why it works.

I have only started working with HG in the last 4-5 months and with that I am starting slowly, relying on existing functionality to get my setup working.

But very recently I have started to expand and part of that has been testing the weather alerter, which includes trying to gain an understanding of how it's working (I was able to make some small code changes as part of that to get it working based on Tuicemen's directions).

Not that I am planning currently to write something of my own as of now, but if I did I would follow the same approach he did here

As they say, there is more than one way to skin a cat.
Title: Re: 🌪️Weather Alerter for HG
Post by: Tuicemen on December 28, 2019, 04:49:19 PM
I posted this Program in the OP ( http://forums.x10.com/index.php?topic=30949.msg181860#msg181860 )
You'll need the latest version of HG as it uses the Open weather program in it.
This gives any device configured in HG the options to trigger on any of the conditions listed in WeatherAlerter.
Note: The ability to trigger on humidity values will require an edit to the Openweather program to function.
Title: Re: Weather Alerter for HG
Post by: Tuicemen on March 22, 2021, 11:25:37 AM
I reworked this  adding the ability to specify what weather program to pull the info from. However this would require the program to be configured to posting values with same names as OpenWeather does. (I've only tested this with OpenWeather & a modified OpenWeather Program that adds the humidity code)

I also added to allow values from a thermostat  or sensors temperature & humidity values and to trigger events based on values. This would also require the sensor to be posting said values as Temperature & Humidity. (tested this with My-EcoBee and Indoor DHT sensor programs)
This uses the same widget as posted in the OP. >!