Getting Ambient Weather Data into Ignition

I wanted to learn how API’s work, so I figured bringing in some of my weather station data to an Inductive Automation’s Ignition project would be a good task to learn on. I wasted a lot of time trying to use the python helper functions that were recommended in the docs at https://ambientweather.docs.apiary.io/. The problem with that route was that Ignition uses it’s own instance of python (actually jython)and it’s an older version. Note: if you do need to import libraries, I finally learned you can use the pip install command which takes care of all the dependencies for you if you follow the directions at https://forum.inductiveautomation.com/t/procedure-for-installing-python-libraries-from-source/26022/2. I almost had it working, but ran into a problem with a codec, which I didn’t understand and didn’t want to figure out.

I wound up using Ignition’s system.net.httpClient() function to make the call to the API. Once I figured out how to format the API call, the hard part was figuring out how to pick through the JSON document it returned and update tag values within Ignition with those values. I couldn’t get any of the built-in functions that are supposed to help with this to work correctly. The documentation is pretty sparse on those functions and it seemed to get hung up on the fact the date values contained colons. My workaround was to convert it to a big string value, then use python’s string commands to find the parts I wanted.

Below is the script I use to do the work. The script runs every 5 seconds. One of the software developers at Ignition had a much more elegant script started, but the get_data() method had a problem and I just went with a simpler solution.

#get data from ambient weather API
client = system.net.httpClient()
response = client.get("https://api.ambientweather.net/v1/devices/00:0E:00:00:00:00", params={"apiKey":"xxx","applicationKey":"yyy","limit":"1" }) 
#comes in as a list
weatherdata = response.json
#convert to a string to deal with problem of time having colons
weatherdataString = ' '.join(map(str, weatherdata)) 

#change searchterm for each element you want
searchterm = "tempf"
offset = len(searchterm)+3
startpoint = weatherdataString.find(searchterm)
endpoint = weatherdataString.find("'",startpoint+offset)
system.tag.write("[default]wxstation/temperature",(weatherdataString[startpoint+offset:endpoint-2]))

#change searchterm for each element you want
searchterm = "yearlyrainin"
offset = len(searchterm)+3
startpoint = weatherdataString.find(searchterm)
endpoint = weatherdataString.find("'",startpoint+offset)
system.tag.write("[default]wxstation/yearlyrain",(weatherdataString[startpoint+offset:endpoint-2]))

#change searchterm for each element you want
searchterm = "dailyrainin"
offset = len(searchterm)+3
startpoint = weatherdataString.find(searchterm)
endpoint = weatherdataString.find("'",startpoint+offset)
system.tag.write("[default]wxstation/dailyrain",(weatherdataString[startpoint+offset:endpoint-2]))

Posted in Industrial Automation | Tagged , , | Leave a comment

Loft Ladder

I built a ladder out of 2×4 and 1×4 lumber. It has 9 rungs spaced 12-3/4″ apart and is set to be used at a 70ยบ angle and have 9′-1″ of elevation.

Posted in Projects | Tagged , | Leave a comment

How-To Get Clean Dishes with a Modern Dishwasher

If your modern high-efficiency* dishwasher is anything like mine, then it is a source of constant frustration. Even with pre-washing the dishes don’t come out very clean.  I think I solved the problem, here is what we do:

  • wash out the filter every time a load is run
  • run it with soap for a normal cycle, which takes several hours (can cancel it during the dry cycle if caught in time) (don’t use too much soap — filling the cups full is usually not necessary)
  • pour a gallon of clean water into the base, then press the drain/cancel button
  • repeat with another galon of clean water, then draining
  • run it again but without soap on the 1-hour cycle

The extra steps are necessary to wash away all the soap.  There are 2 things you are fighting**: 1) the soaps no longer have the ingredient in them that allow for easy rinsing, and 2) a typical cycle only uses 3 gallons of water, instead of the traditional 15 gallons.

*water usage efficiency, not time efficiency
**both of the changes are due to US law

 

 

Posted in How-To, Information | Tagged , , , | Leave a comment

2018 Scouting Memories

Posted in Family | Tagged , | Leave a comment

Aiden Ding Dong Ditcher

I sent Aiden outside today because he was being too loud. This is what he did.

Posted in Family | Tagged , | Leave a comment

Canonball Speed Sensors

A customer wanted to use industrial photo eye sensors with a piece of lab equipment to measure the speed of a projectile shot out of a air cannon.  I assembled a small box with the parts needed to power it and adjust the voltage levels. 

Posted in Industrial Automation | Tagged , , | Leave a comment

Batch Resize Pictures Using Linux Convert Utility

A quick and simple way to resize a folder full of pictures is to issue the following command on a Linux computer:

$ for file in *.jpg; do convert $file -resize 25% rz-$file; done
Posted in How-To | Tagged , , , , , | 2 Comments

Dasher the Dog 2003-2018

Posted in Family | Tagged , | 1 Comment

WeatherCam online

I hooked up an old analog camera I had laying around (one of the 15!) to an Axis 2400+ video server I bought off of ebay for $40.  A little script that runs every minute and copies a picture from zoneminder to my webhost account.  I added the picture as a widget to this website in the sidebar under the weather station doohickey.   Once I verify the picture quality in the daylight, I’ll add it the weather cams at wunderground.com.

Continue reading

Posted in Projects, Technology | Tagged , , , | Leave a comment

Kodi, Sling, Plex, MythTV Entertainment Options

In a more-complicated-than-need-be step to canceling our satellite TV service, I installed MythTV backend and Plex server on an old computer that was sitting around.  I started by installing mythbuntu because I’m already comfortable with using Ubuntu.  MythTV uses the inexpensive HDHomeRun tuner as a source for local TV channels from the antenna, and it also has all kinds of capabilities to get content and information from the Internet and your local video libraries.  Plex is service that not only finds and matches cover art and artist information to your existing content, but it has the magical ability to transcode your content on the fly when the client needs a different format.

 The piece of this project that really made the biggest difference was that Kodi, which can be a front end for MythTV (and much more) can be installed on an Amazon Fire Stick.  

Continue reading

Posted in Projects, Technology | Tagged , , , , , , , , | Leave a comment