Back To Work On The Web Site

I must have gotten my energy back as I’ve made several more updates to the Web site.  I put the newest advisories Web page into production.  I also did some minor tweaking to make some of the transitions look a little smoother.  Alerts slide up and down rather than just popping in and out of view.  I also toyed around with ways to highlight changed values when the weather data updates dynamically.  I tried making the text fade in and out.  I also tried having it appear in a different color for a few seconds and then change color to match the rest of the page.  That particular effect is used by Weather Underground and by several other personal weather pages.  But in the end I decided I didn’t really like it and put things back so that updated values just change to the new value without drawing any attention.

The next thing I did was test my pages on a browser that doesn’t have JavaScript to see how they behave.  I had to make a few changes to make sure there is static text displayed in those browsers since they can’t update the page dynamically through JavaScript code.  So things like alerts don’t update when they change, but they do display whatever was in effect when the page is first loaded.  Some of these changes required having static and dynamic sections on a page.  The static sections display by default.  JavaScript code hides the static sections and displays the dynamic portions.  Browsers that do not have JavaScript will display the static portion as they can’t run the code to display the dynamic portions.  So now I have some new browsers to test with when I update my pages.  And yes, I do still need to zip and post the updated code to the download area of the Web site.

Finally, I have updated my Raspberry Pi in preparation for using it as my newest weather station computer.  My current one works fine.  My only complaints are that it draws more power than the Pi and won’t run as long on battery backup.  I am adding an external hard drive so that the constant updates to the weather data don’t “wear out” the SD card.  Hopefully time will allow me to complete that project in the next few weeks.

More Bug Squashing

Now that I was paying more attention to the Web site, I decided to make the alerts page more dynamic in order to address another nagging issue.  If an NWS alert went into effect or expired while a user had the page open, the alert would display or clear itself dynamically on the banner at the top of the page.  All of my pages have this capability.  The issue is that the alert details displayed below on the weather advisories page do not update dynamically to match the banner.  Also, the weather discussion and weather outlook were static and didn’t update over time if the page was left open.  So I set out to make the entire page update dynamically.  Using Knockout made short work of that item.  I just needed to build server side pages to retrieve and return the data in JSON format.  On the client side I modified the page to periodically retrieve the alerts, details, and discussion information and update the display.  I got that working well and decided I should confirm that everything was working in other browsers.

Firefox and Chrome worked fine.  Then I tried IE11.  Not only did this page not display correctly, but none of my other pages were updating either.  This puzzled me because I was sure it was working previously.  I must not have ever tested with IE11.  So now it was time for some frantic debugging to take place.  I eventually narrowed it down to a custom event I was using that wasn’t firing when the data was retrieved.  This was the event that caused the page to display any updated data.  If I refreshed the page the event would fire correctly.  It only happened on the initial load of the page.  So none of my dynamic pages were updating dynamically in IE11.  Not good.

After I pondered this for a while I wondered why I was using an event in the first place.  I’m pretty sure it had to do with the fact that there were different schedules for retrieving the different types of data, and the different functions that got called to refresh the page.  At one point in the past I had consolidated all of those functions, so now i had the ability to just call it directly without triggering an event.  I made that change and all the pages worked in all the browsers I tested.  Success!

During this process I also decided to update the versions of Minify, jQuery, and Knockout I was using to the latest versions.  I didn’t really see a difference from that change, but I hadn’t updated them for a long time so it was overdue.  I also took the opportunity to add a bit more error checking and console logging to my JavaScript code.  That should help debugging in the future.I also added a local alerts page that displays alerts created by our local county.  I ended up moving the Government status updates off of the traffic page and adding it to the local alerts page as well.

I still haven’t updated the source code zip file on the software Web page.  Hopefully that will come soon.  I also haven’t put my new and more dynamic weather advisories page into production yet.  Testing has been fine so far, but i may want to tweak a few things before I release it.

Software Update

I haven’t added a blog entry for quite a few months now.  The weather station has been performing well on “auto-pilot” for all of this time and I have no complaints.  But there were some nagging issues with the software I finally got around to correcting.

The first issue was that it didn’t handle cases where it was unable to retrieve a valid forecast from the NWS very gracefully.  At least not in all cases that were occurring.  I had some error checking in the code, but I was able to improve on it quite a bit.  Now when the software is either unable to retrieve the forecast or it determines that the forecast XML might not be valid it retains the prior forecast, saves the error information in an error file, and does a retry the next time the forecast is requested.  Prior to making this update it was possible for the software to fail parsing the forecast XML.

The second issue was not really a problem, just an enhancement.  When the software retrieved weather advisories sometimes there were additional details available.  The software now retrieves those details when available and formats the display a bit more cleanly.

The third issue was that there was no password protection on my page that received the weather data from my weather station server.  It previously did some minor error checking in an attempt to prevent malicious people from uploading bogus data.  The page is now password protected which adds a bit more protection from receiving bogus data from an unknown source.  This is certainly not iron-clad security, but it is quite a bit better than the security scheme I had in place before now.

I will get around to uploading the newer files to the site as soon as I can.  I see that a few people have downloaded the software.  Hopefully you found it useful.

Software Released

I chose to make the software that powers my weather station as well as the web site available for others to use if they so desire.  The software is available at http://www.cloppermillweather.org/software.php.  If anybody decides to try it let me know how it went.  It isn’t very polished, so if you aren’t interested in creating or modifying configuration files by hand it may not be the best choice for you.

Favicon

Just for grins, I added a favicon.ico to my weather web site so that browsers can show a little icon when the a user bookmarks a page on that site.  The icon also shows up in the browser’s tab for that page or in the address bar, depending on the browser.  That was all simple enough, but I wanted to attempt to take it a step further.  So I added some code to the class that retrieves the weather forecast that is displayed on the web site.  The new code converts the image for the current weather into an icon and stores it as favicon.ico.  I also added some code to the Web page that refreshes the icon every time the forecast is refreshed.  So now the favicon shows the current weather forecast.  This works really well in Firefox and Chrome. IE doesn’t always refresh when I would expect it to.  So not a total success.  But it was entertaining.  I may come back to it sometime and see if I can get IE to refresh a bit better.

Webcam Update

The weather station has been mostly on auto-pilot for several months now.  I do still check the logs and keep an eye on things, but it hasn’t required any real intervention on my part.  I’ll consider that a good thing as my attention has been focused elsewhere for the last few months.  The only real issue I was having with the weather station was the webcam software.  I had begun experiencing periodic lockups of the software where the image was no longer being captured or uploaded to my web site.  I had been using a trial version of Conquercam, which is not free software, so it was time to either pay up or find an alternative.

In the past I had looked at several free webcam packages.  My favorite had been Yawcam.  I don’t remember all the details, but I remember I abandoned that software because I was having to unplug and plug in the webcam fairly often to reset the driver.  My server had a fairly fresh install of Windows Server 2012 Essentials, so when Conquercam began having issues I decided to give Yawcam another chance.  I’m happy to say that Yawcam has performed quite well for me since I switched back to it.  It also has the advantage of being able to provide better streaming support.  For Conquercam I was using a page that refreshed the image every second rather than doing actual streaming.  Yawcam provides a Web page with fairly decent streaming support. So for now I’m a Yawcam user again.  It’s been running for several weeks now without a hitch.  I’ll continue to keep an eye on it and report back here if I have any problems with the software.

New Data Upload Method

I’ve been using FTP to transfer my weather data, statistics, and history to the cloppermillweather Web site.  This has worked fairly well, but I didn’t want to be dependent on my ISP providing FTP.  I knew I could create a PHP Web page to accept data.  I thought I might be able to use wget to do an HTTP POST with the data files I wanted to upload.  So I did some researching and discovered that curl was fully capable of doing what I wanted.  So I created a simple PHP page to accept a file and modified my FTP scripts on my weather server to use curl instead of FTP.  Everything is working great with a little less overhead than my prior FTP scripts.  I also added some simple validity checks on the upload page to make sure the data is good.  Not all that secure (at least not yet), but the concept works just fine.  Here’s a generic curl comand to post a file:

curl -F”operation=upload” -F”file=@fileToUpload” http://URLToReceiveHTTPPost

One thing to watch out for is if the destination site sends back an HTTP 301 redirect.  Curl has an option to follow the redirect and do a subsequent POST.  Most browsers will follow the redirect but refuse to do the HTTP POST after the redirect.  This is actually a security feature, so make sure you know where you are being redirected to before POSTing anything you want to keep private.  Weather data probably isn’t something where privacy is a concern, but the warning applies if you are using this technique for other types of data.

Admiral Hopper Would Be Proud

As a software developer I deal with bugs on a regular basis.  Probably more regular than I want to.  The origin of the term bug was attributed to Admiral Grace Hopper when she and her team reputedly found a moth in a mechanical relay on the computer they were working with.  Or at least the story goes something like that.  But now I can totally relate to that experience.  I noticed that the outdoor temperature readings from my station were higher then the surrounding stations or even than my outdoor thermometer I have in another part of my yard.  I thought that maybe the fan in my aspirated solar shield was running hot and raising the temperature.  Upon checking, I found the fan wasn’t turning at all.  After I took everything apart I discovered three things.  First, the connector I used to wire up the fan was more corroded than I would have liked.  Second, there was a large beetle of some sort whose carcass was stuck in the fan blades and preventing it from turning.  Third, the fan was blowing air (or would be if it had been turning) over the temperature sensor rather than pulling air past it.  I cleaned out the fan blades, turned it around to blow in the other direction (reversing polarity didn’t work), and reconnected the fan.  The temperature started dropping immediately.  I’ll keep a close watch on it over the next few days.  I’ll also look for a more waterproof connector to replace the one I have on there now.  I knew better, but it was what I had handy and I thought it would be protected enough inside the solar shield.  Anyway, I appear to be back in business.  The next few days will tell for sure,

Posting Data To Weather Bug

I had looked into posting my weather data to Weather Bug at some time in the past, but wasn’t able to get any information on how to interface with that service.  So I left it alone and forgot about it.  For some reason I chose to revisit that issue, and learned that they published the interface specs some time ago.  Using that specification it was pretty easy to add the posting of my weather data to Weather Bug.  It was very similar to the scheme used by Weather Underground, to the point of even using many of the same parameter names.  So now I am station ID number P15087 on Weather Bug.  Here’s a URL to the station data.

Guruplug Passed On

I started having issues with the Guruplug that I use for my station computer.  The file system kept getting corrupted and was being made read only.  It finally reached the point where it wouldn’t boot anymore at all.  So I pressed a workstation I had nearby into service as a replacement.  This computer is an older workstation running Centos Linux.  It took me a while to get everything set up as I didn’t have backups for all the configuration files and scripts.  Most of them were backed up, but there were a few I had been tweaking on the Guruplug.  I back up all my Windows workstations nightly, but never implemented a backup solution for the Guruplug.  That was a mistake that I will correct ASAP.

The new station computer is working well and is much more capable that the Guruplug could ever hope to be.  The benefit is that the weather data is updated more frequently.  The downside is that my UPS can only run this computer for several hours rather than several days for the Guruplug.  Maybe I can come up with an old laptop which should extend the run time a bit.  But for now the station is back up an running again.