Powershell Script for Weather text overlay
Powershell Script for Weather text overlay
I wrote a pretty sweet powershell script that grabs the current weather conditions from NOAA and generates a {weather}.txt file. It's fully customizable and easy to manipulate. It can be run as a scheduled task as well. Anyone interested? PM me.
The Script
Some one PM'd me and asked for the script. So I thought I'd share with everyone.....
This requires you have Powershell installed:
Here is the Script and Instructions:
Visit : http://www.weather.gov/xml/current_obs/
Locate your location and notice the code for your chosen weather station, for instance:
Kickapoo Downtown Airport (KCWC) - This location code is KCWC
Edit the ps1 file that you will save and change the URL where it says YOUR LOCATION CODE, to your location code. For instance:
Save it as "weather.ps1" in %userprofile%\.yawcam\extravars
You can add or remove variables in the last line to make it look however you want. Just follow the syntax already specified and use the variables from the list above. You may have to change %userprofile% on the output file variable declaration to the actual path instead of using the system variable. It's a very simple script.
In YawCam: Settings -> Edit Settings -> Overlay -> Text
- Enter {weather} as the text to be displayed, set the location, font etc. to your preference.
Create a scheduled task that runs this command every x minutes/hours, whatever you want...
Be sure to set it to start in the same folder as the script.
You can set it to run as the local computer administrator to hide the window.
It's a little Techy, hope you can follow. Nothing to terribly difficult. If you have a question about something Google is a great resource. ENJOY!
This requires you have Powershell installed:
Here is the Script and Instructions:
Visit : http://www.weather.gov/xml/current_obs/
Locate your location and notice the code for your chosen weather station, for instance:
Kickapoo Downtown Airport (KCWC) - This location code is KCWC
Edit the ps1 file that you will save and change the URL where it says YOUR LOCATION CODE, to your location code. For instance:
Code: Select all
http://www.weather.gov/xml/current_obs/KCWC.xml
Code: Select all
[xml]$xml = (New-Object System.Net.WebClient).DownloadString("http://www.weather.gov/xml/current_obs/YOUR LOCATION CODE.xml?item=All")
$output_file = "%userprofile%\.yawcam\extravars\{weather}.txt"
$location = $xml.current_observation.location
$temp = $xml.current_observation.temp_f
$longitude = $xml.current_observation.longitude
$latitude =$xml.current_observation.latitude
$weather = $xml.current_observation.weather
$humid = $xml.current_observation.relative_humidity
$wind_detail = $xml.current_observation.wind_string
$wind_direction = $xml.current_observation.wind_dir
$wind_MPH = $xml.current_observation.wind_mph
$wind_chill = $xml.current_observation.windchill_f
$visibility = $xml.current_observation.visibility_mi
$dewpoint = $xml.current_observation.dewpoint_f
$pressure = $xml.current_observation.pressure_in
"$($temp)ºF - $($humid)% Humidity - Wind: $($wind_MPH)MPH - Wind Chill: $($wind_chill)ºF - Pressure $($pressure) - $($weather)" | out-file $output_file -encoding default
exit
In YawCam: Settings -> Edit Settings -> Overlay -> Text
- Enter {weather} as the text to be displayed, set the location, font etc. to your preference.
Create a scheduled task that runs this command every x minutes/hours, whatever you want...
Code: Select all
powershell -file %userprofile%\.yawcam\extravars\weather.ps1
You can set it to run as the local computer administrator to hide the window.
It's a little Techy, hope you can follow. Nothing to terribly difficult. If you have a question about something Google is a great resource. ENJOY!
-
- Posts: 4
- Joined: Tue Sep 20, 2011 11:25 pm
This works perfectly. We currently have it in use with out outdoor webcam we have at: http://epicwebstudios.com/cam
Thanks again!
Thanks again!