[RELEASE] Precipitation and Weather Monitor for National Weather Service Data (USA Only)

Thank you for this weather driver. I've created a virtual device for it, and now it's a tile on my dashboard.

Question: Could somebody point me in the right direction on how to create a virtual switch just based on the Temperature variable in this driver? I would like to turn on my bird bath heater when the outdoor temperature is < 32 deg F (0 deg C). Everything I have tried with the rules engine seems to want an actual temperature device. Seems like I should be able to create a device just based on this Precip and Weather Monitor, no?

Thank you,
Bill in Maryland, US

I’m glad you find it useful. I implemented temperature and other numeric values as attributes. I probably should have just chosen the various named attributes but this seemed better at the time. So what you need to do is select “attribute” when writing your rule and it will give you a list to pick from and you’ll pick the attribute named temperature for example. Same for all drivers accessing those types of attributes.

Hope that helps.

Could others using this driver take a look at their State Variables and tell me if the number of those retained exceeds the driver setting per this example.

On mine these records keep building up. I've looked at the code and the logs and it attempts to remove these state variables but they don't actually get removed on my system.

Other having the same issue?

Doing a ClearAll works but the removeExpired does not.

I just installed the app/driver via HPM. It looked like everything installed correctly and I was able to create the virtual device but I can't get it to pull data. I'm using ICAO code KGME. I checked the log and I keep getting the following error on refresh:

groovyx.net.http.HttpResponseException: status code: 404, reason phrase: Not Found on line 338 (method refresh)

refresh(): A data refresh has been initiated.

Has anyone had this issue? Or know what I'm doing wrong?

404 means "Not found" -- that the URL it's trying to fetch is not finding a page. It probably means you entered the Airport Code incorrectly. "K" + your desired Airport.

Yep, no airport with code KGME

Use the link to the Wikipedia page on the OP for a list of valid codes.

1 Like

That was it. I was supposed to use KMGE. Tpyed it correctly and it is working now. Thanks for the help.

Gary - I have an enhancement request in the event you are making updates. Is it possible to add an additional variable in the preferences for the time window to calculate the watering threshold (instead of just yesterday)?

FYI there is an update to version 1.0.2 to correct a bug where the old records were not getting purged and kept piling up in state. If you don't look at the driver you may not have noticed but this update should keep the number of retained records at the number specified in Data Retention Period in Hours. * within settings.

Does not change functionality, just improves appearance.

I've been meaning to ask, is there a reason the minimum is 48 hours? I don't care about that much history and I'm trying to preserve memory...

Sorry, not really doing feature adds at the moment, just bug fixes. My development energies are going into Tile Builder at the moment. There will be a new module released in the next few days which may be a good way of displaying the NWS data.

Yes, it calculates total rainfall for today and yesterday by adding up the rainfall amounts for each hour. If less than 48 hours of data were kept then rainfall totals for the prior day could be inaccurate.

Ah. Well, to be honest I only use this driver to give me the current weather observation for the closes NWS station. Don't use the other info so that's why. I wouldn't mind a fork of it if I was smart enough to do it.

It's not a big program (700 lines) so it would be pretty easy to bypass all of the other stuff. Never too late to start programming and this would be mostly deleting what is already there.

I'd probably just add a boolean option like "Collect Rainfall Data" and use an if statement to bypass the necessary sections. Then change the number of hours to retain to something like 2.

I might do it. Truth is I programmed full-time from 1980 until 2000 or so when I moved into management and lost touch. Fortran, Assembly, C, C++, Java etc. But, rusty doesn't begin to describe it. But, I think it's a worthy project. Thanks for the inspiration Gary.

Things have changed a lot since then but logic is still logic. I think you'll really enjoy it. If you want to make it an enhancement anyone can use, then I'd be happy to post it out so it's available to everyone through HPM.

One thing I'd absolutely use is chat gpt. It is a great resource. I asked to explain a piece of code from the driver and you can see it's response. You can also ask it to write code but it's not always correct.

I'll give you a hand if you get stuck.

explain this function: def purgeExpiredRecords(retainList){
log ("purgeExpiredRecords", "Purging expired records!", 1)
int maxRecords = 31 * 24
int i = 0
while ( i < maxRecords ){
variable = "R-${i}"
def value = state."${variable}"
if (value != null ){
//log.info ("State Variable ${variable} exists and value is: ${value} " )
//So there is state variable by this name. Let's see if it is in the retainList
if ( retainList.toString().contains(variable) == true ){
log ("purgeExpiredRecords", "Preserved record: " + variable , 1)
}
else {
state.remove(variable)
log ("purgeExpiredRecords", "Purged record: " + variable , 1)
}
}
//A small pause to stop the driver from hogging all the resources as this is an intensive loop otherwise.
pauseExecution(10)
i++
}
}

ChatGPT
The provided function, purgeExpiredRecords, is designed to remove expired records from a state based on a given retainList. Here is a breakdown of how the function works:

It begins by logging a message indicating that the purging of expired records is starting. The log message is printed with a severity level of 1.

The variable maxRecords is set to the value of 31 multiplied by 24, which equals 744. This represents the maximum number of records to be checked.

A loop is initiated with the variable i starting at 0. The loop continues as long as i is less than maxRecords.

Inside the loop, a new variable named variable is assigned a string value in the format "R-${i}", where ${i} represents the current value of i.

The function attempts to retrieve the value of the state variable named ${variable}. The state object is assumed to be a container for storing variables.

If the retrieved value is not null, it means that a state variable with the name ${variable} exists.

The function checks if the retainList contains the variable by converting retainList to a string and using the contains method. If the retainList does contain the variable, a log message is printed indicating that the record is preserved. Otherwise, the state variable ${variable} is removed, and a log message is printed indicating that the record has been purged.

After processing each record, the function pauses execution for 10 units of time. This pause helps prevent excessive resource usage during the intensive loop.

The variable i is incremented by 1, and the loop continues until i reaches maxRecords.

In summary, the purgeExpiredRecords function iterates over a range of record names and checks if each record exists in the retainList. If a record is not in the retainList, it is removed from the state.

1 Like

Great driver! Just what I was looking for. Quick question - I added the device to a dashboard and specified “weather” as the template.

It shows Humidity, Temp, and Wind Direction labels but no data. The data are shown on the device itself, as well as the device list (I selected temperature as the display value).

Is there something else I need to do, or will the data populate on the dashboard after a while?

That template is probably expecting certain attribute names/data types. You can put on individual attributes but that takes up extra space. This scenario is why I created Tile Builder which lets you add a variety of attributes within a single attribute. For example:
image

You can use the module called Multi Attribute Monitor and you can read about it here.

I finally got around to utilizing my own driver to control my sprinklers.

I found this to perform the on\off scheduling.

and I've added some capabilities to the upcoming version of Tile Builder Grid to be able to present sprinkler data on the dashboard without having a smart sprinkler system.

image

Should be able to save some money on water this summer and the whole thing only cost me $50 for the 8 port Tasmota relay and an enclosure.

1 Like

I have switched from the OWM driver to this one. I didn't want to switch to the new API and give them CC info. This driver provides everything I need, and I think will be more accurate for my local weather as a local regional airport is only about 10 miles from my house.

So thanks for this.

1 Like

(post deleted by author)