Hope this helps someone else out there, I had a lot of trouble finding information on how to do this while setting up my weather information!
This is my script on how to pull weather information out of the Darksky API, parse the resulting JSON into a nice text file, and bring it into PI using UFL. I'm sure there's a much more elegant solution to this, and I'm always open to suggestions, but this works for my purposes at the moment.
- Sign up for a darksky API account here: Dark Sky - you get up to 1000 free API calls per day.
- Download and extract the folder attached and put it into your UFL Config folder (or wherever you drop stuff for UFL to pick up). In the example, the file is located on D:\UFL CONFIG\Current Weather\ and the forecast "$dst" is located in a sub folder: D:\UFL CONFIG\Current Weather\Forecast\
- You'll need to specify where the text file ($dst) is in the ini file as well
- Create new PI tags to hold the information. There will be a total of 15 tags if you don't modify anything from this example.
- Open the powershell script - modify the $src to include your API key, latitude and longitude - please note that latitude and longitude are absolute for this particular application. Modify the $dst file for where you want the text file to end up
- Create a new windows task (super advanced over here!) to run your script - FYI you'll need to perform this with admin privileges.
- Create a new task, set it up to run every 2 minutes indefinitely (or more, your choice) on the triggers tab.
- On the actions tab make sure to include this information:
- Action: Start a program
- Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
- Add arguments (optional): -ExecutionPolicy Bypass -File "**change me to your powershell script address**"
- Save your task, and start it running. You should start getting a text file with your weather data in the file you've specified.
- Open up PI ICU - create a new interface. I've attached photos for each tab, edit the information as needed to get things working. If you want, you can use the UFL designer to customize this, otherwise use the .ini file I've included in the attachments.
- If you use the example, open up the .ini file in your UFL config folder - modify the IFM (file location for your text file), tag names (down at the bottom, currently CW.xxxx)
You should have weather information start showing up once the interface is set up and running