Blue Iris Tools - Weather Overlay, Watchdog & more!

Blue Iris Tools - Weather Overlay, Watchdog & more! 1.6.0

Joined
May 15, 2018
Messages
8
Reaction score
6
Location
BGM
Ok, I've included my procedure for adding weather overlay on to my BI Camera's.. The procedure once setup is pretty simple but if you haven't done this before, I hope my procedures help you.

How to insert Weather Data into BI Camera overlays

Note:
I use the “ ” double quotes within this procedure to denote what to expected and the quotes should not be added to the text enclosed, however there is an exception and that's associated with the PowerShell Script file, it uses double quotes within the code, so instead I used "* " (star) character delimiter to denoted items between * xyz * star character that needs to be changed to reflect your circumstances, once you've update the file ensure that you've remove all of the (star) character(s).

Setting up the Necessary Directories
  1. You need to create a two directories' one for your “My BI Overlay.Bat” and “Pulling the weather data script for BI.ps1” PowerShell script files and the second for your updating weather Info text file.
  2. Open file explorer and navigate to This PC > C: (your C: drive).
  3. Using your mouse right click on the explore screen to get "New" option > Folder, Rename the new folder to "BI"
  4. Double click the "BI" directory, you should have a empty folder
  5. Using your mouse right click on the explore screen to get "New" option > Folder, Rename the new folder to "TXT" (this is where your updated weather text file will be stored).
  6. Place both “My BI Overlay.Bat” and “Pulling the weather data script for BI.ps1” files within the C:\BI directory.
  7. Make the necessary changes within the “Pulling the weather data script for BI.ps1” file, look for the * (star) characters this is where you will have to change the contents between * * (star) characters with your particulars and make sure to delete the * (star) characters as they are only visual delimiters for you.

Run PowerShell
From the Windows Start Menu

  1. Click Start, type PowerShell, and then click Windows PowerShell,
  2. You should now have a "Windows PowerShell" Window open with the cursor waiting for input.
  3. Manual Go/NO-GO testing: enter the following text below, followed depressing "Enter" or Return key.
Code:
& 'C:\BI\Pulling the weather data script for BI.ps1'
  1. You should get the following message displayed "The operation completed successfully." along with scrolling weather-related information if so then you're working!! proceed to Run Task Scheduler, otherwise...
  2. I have an Error Message (you can scroll up/down) displayed, try to determine if it's 1) "Unable to run PowerShell scripts or 2) Can't find "Condition" command that is used within the Scrapper code for Weather Condition.
  3. If you have determined that its Error 1) then proceed to PowerShell Error type I resolution.
  4. If you have determined that its Error 2) then proceed to PowerShell Error type II Resolution.

PowerShell Error type I

Note: If this is your first-time running PowerShell you will most likely not be able to run Scripts (you will get an error message letting you know) as Windows is turned off by default, to fix this you must do the following (one-time event);
  1. First, Open PowerShell with Run as Administrator
  2. Then, run this command (below) within the command line and depress enter:
Code:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
  • After that Type “Y” and Press Enter
  • You will now be able to run PowerShell scripts.
  • Proceed to "Run Task Scheduler" process.
PowerShell Error type II

Download a new copy of PowerShell and "Bob's your Uncle!" it worked as advertised.. the many mysteries of Windows.....

To install or update the PowerShell app using Microsoft Store, use the following steps:
  1. Open the Microsoft Store app (icon) on your PC.
  2. Use the search bar at the top to locate the PowerShell app on the store.
  3. Click the Update / Get button to update / Get the PowerShell app.
  4. Proceed to "Run Task Scheduler" process.

Run Task Scheduler
From the Windows Start Menu

Click Start, type Task Scheduler, and then click Task Scheduler.

You should now have a Task Scheduler Panel. On the right side in the action panel select “Create Task” you should now have a Create a Task dialog screen
  • Enter “BI Weather Overlay” in the Name: field,
  • Select “Next”, you will now have “Task Trigger” select “New”
  • You should now have “New Trigger” screen, make sure that “Daily” is selected.
  • Select “Repeat task every:” and change the drop down to “15 minutes”
  • Select “for a duration of:” and change the drop down to “Indefinitely”
  • Select “OK”, you should have a newly created Trigger.
  • Select Actions Tab followed by “New” you should have a New Action with Action: set to “Start a program” selected if not change to reflect it.
  • In the Program/Script: field enter “C:\BI\My BI Overlay.bat”
  • You now have a working Task Scheduler that will execute your bat file every 15 minutes which will run your PowerShell script to create a new Weather.txt file output to be used in Blue Iris Overlays

Blue Iris Overlay Process
  1. In the Blue Iris app, goto Blue Iris Settings > Macros where you will see Macro %1 thru %9, change the first one “%1": and add "file:/C:\BI\Txt\Weather.txt" (not the " " characters)
  2. Goto the camera that you want to insert the overlay by right clicking the camera in question and selecting “Camera settings… > Video",
  3. Ensure that “Display overlays live” is selected,
  4. Goto “Edit overlays” select “Add text/time” at the top of Text overlay input field enter “%1”, you can change alignment to Left and set the Font Color to Yellow or whatever, depress enter.
  5. You can now move the "Weather overlay" to your desired placement by dragging with mouse and stretching to enlarge or reduce text size.

File content (Details), I've also attached the two files in question within a zipped file.

My BI Overlay.Bat” contains the following command (it runs PowerShell with the appropriate Script);

Code:
@echo off
PowerShell -command "& 'C:\BI\Pulling the weather data script for BI.ps1'"
Pulling the weather data script for BI.ps1” contains the following commands: (Note: you will have to change the contents between * * characters with your particulars and make sure to delete the * as they are only visual delimiter for you)

Code:
# /Pulling the weather data from two sources: Weather Underground, and weather.com, a string is formed with the requested data points.
# /wunderground is being html scraped for the condition shown on the site.
# /weather.com runs the API for Wunderground. It is pulling the time, temp, and wind conditions from the at-home wx station.
#
# /Create a registry value that should accept the silly cookie warning from wunderground.com... it gets deleted at the end of the script
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /t REG_DWORD /v 1A10 /f /d 0
#
# /SCRAPE THE WUNDERGROUND PAGE FOR THE CURRENT CONDITIONS
$UrlWUCond = "https://www.wunderground.com/weather/us/*Your State Abv*/*Your City*/*Your PW Station ID*"
$searchClass = "condition-icon small-6 medium-12 columns"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 <# using TLS 1.2 is vitally important #>
$req = Invoke-Webrequest -URI $UrlWUCond
$Condition = $req.ParsedHtml.getElementsByClassName($searchClass)[0].innertext;
#
# /POLL THE WEATHER.COM API TO GET THE CURRENT OBSERVATIONS
$UrlWU = "https://api.weather.com/v2/pws/observations/current?stationId=*Your PW Station ID*&format=json&units=e&apiKey=*Your WU API Key*"
$CurrentWeather = Invoke-RestMethod "$UrlWU"
$CurrentWeather | ConvertTo-Json -depth 100
#
# /CONVERT THE WIND AND COMPASS DIRECTION FROM THE WX STATION TO BE A UNICODE ARROW AND CARDINAL DIRECTION
# (i.e., wind out of the East will show an arrow pointing West, and the Cardinal direction):
#
if ($CurrentWeather.observations.winddir -gt 22.5 -and $CurrentWeather.observations.winddir -lt 67.5) {$arrow = $([char]0x2199)}
elseif ($CurrentWeather.observations.winddir -gt 67.5 -and $CurrentWeather.observations.winddir -lt 112.5) {$arrow = $([char]0x2190)}
elseif ($CurrentWeather.observations.winddir -gt 112.5 -and $CurrentWeather.observations.winddir -lt 157.5) {$arrow = $([char]0x2196)}
elseif ($CurrentWeather.observations.winddir -gt 157.5 -and $CurrentWeather.observations.winddir -lt 202.5) {$arrow = $([char]0x2191)}
elseif ($CurrentWeather.observations.winddir -gt 202.5 -and $CurrentWeather.observations.winddir -lt 247.5) {$arrow = $([char]0x2197)}
elseif ($CurrentWeather.observations.winddir -gt 247.5 -and $CurrentWeather.observations.winddir -lt 292.5) {$arrow = $([char]0x2192)}
elseif ($CurrentWeather.observations.winddir -gt 292.5 -and $CurrentWeather.observations.winddir -lt 337.5) {$arrow = $([char]0x2198)}
else {$arrow = $([char]0x2193)}
#
if ($CurrentWeather.observations.winddir -gt 11.25 -and $CurrentWeather.observations.winddir -lt 33.75) {$CardinalDir = "NNE"}
elseif ($CurrentWeather.observations.winddir -gt 33.75 -and $CurrentWeather.observations.winddir -lt 56.25) {$CardinalDir = "NE"}
elseif ($CurrentWeather.observations.winddir -gt 56.25 -and $CurrentWeather.observations.winddir -lt 78.75) {$CardinalDir = "ENE"}
elseif ($CurrentWeather.observations.winddir -gt 78.75 -and $CurrentWeather.observations.winddir -lt 101.25) {$CardinalDir = "E"}
elseif ($CurrentWeather.observations.winddir -gt 101.25 -and $CurrentWeather.observations.winddir -lt 123.75) {$CardinalDir = "ESE"}
elseif ($CurrentWeather.observations.winddir -gt 123.75 -and $CurrentWeather.observations.winddir -lt 146.25) {$CardinalDir = "SE"}
elseif ($CurrentWeather.observations.winddir -gt 146.25 -and $CurrentWeather.observations.winddir -lt 168.75) {$CardinalDir = "SSE"}
elseif ($CurrentWeather.observations.winddir -gt 168.75 -and $CurrentWeather.observations.winddir -lt 191.25) {$CardinalDir = "S"}
elseif ($CurrentWeather.observations.winddir -gt 191.25 -and $CurrentWeather.observations.winddir -lt 213.75) {$CardinalDir = "SSW"}
elseif ($CurrentWeather.observations.winddir -gt 213.75 -and $CurrentWeather.observations.winddir -lt 236.25) {$CardinalDir = "SW"}
elseif ($CurrentWeather.observations.winddir -gt 236.25 -and $CurrentWeather.observations.winddir -lt 258.75) {$CardinalDir = "WSW"}
elseif ($CurrentWeather.observations.winddir -gt 258.75 -and $CurrentWeather.observations.winddir -lt 281.25) {$CardinalDir = "W"}
elseif ($CurrentWeather.observations.winddir -gt 281.25 -and $CurrentWeather.observations.winddir -lt 303.75) {$CardinalDir = "WNW"}
elseif ($CurrentWeather.observations.winddir -gt 303.75 -and $CurrentWeather.observations.winddir -lt 326.25) {$CardinalDir = "NW"}
elseif ($CurrentWeather.observations.winddir -gt 326.25 -and $CurrentWeather.observations.winddir -lt 348.75) {$CardinalDir = "NNW"}
else {$CardinalDir = "N"}
#
$Time = get-date -format "MM/dd HH:mm:ss"
#
# /BLUEIRIS OVERLAY
# checks rainfall. Rain accumulation less than .05" is ignored. Finally, the string is combined to form the weather.txt file output.
if ($CurrentWeather.observations.imperial.precipTotal -ge 0.05) {$json = Write-Output "PWS:$($CurrentWeather.observations.stationID) `nCond:$($Condition) `nTemp: $($CurrentWeather.observations.imperial.temp)°F `nWind Chill: $($CurrentWeather.observations.imperial.windChill)°F `nHumidity: $($CurrentWeather.observations.humidity)% `nWind Speed: $($arrow)$($CurrentWeather.observations.imperial.windSpeed) mph $($CardinalDir) `nRainfall: $($CurrentWeather.observations.imperial.precipTotal)"" `nPressure: $($CurrentWeather.observations.imperial.pressure)"" `nUltraviolet (UV): $($CurrentWeather.observations.uv) `nLast Updated: $($Time)"}
#
else {$json = Write-Output "PWS:$($CurrentWeather.observations.stationID) `nCond:$($Condition) `nTemp: $($CurrentWeather.observations.imperial.temp)°F `nWind Chill: $($CurrentWeather.observations.imperial.windChill)°F `nHumidity: $($CurrentWeather.observations.humidity)% `nWind Speed: $($arrow)$($CurrentWeather.observations.imperial.windSpeed) mph $($CardinalDir) `nRainfall: $($CurrentWeather.observations.imperial.precipTotal)"" `nPressure: $($CurrentWeather.observations.imperial.pressure)"" `nUltraviolet (UV): $($CurrentWeather.observations.uv) `nLast Updated: $($Time)"}
$json | Out-File -FilePath "C:\BI\TXT\weather.txt" -Encoding UTF8
clv -Name Condition
#
# Delete the registry value
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v 1A10 /f
exit
 

Attachments

Last edited:

Brett_F

Young grasshopper
Joined
Jun 21, 2018
Messages
49
Reaction score
10
Location
Canada
Impressive & appreciated that you share your work. My quandary is that my WU broke so long ago I have just gotten use to it no longer around. If this script was around when it first broke, I would have been all over this.
 

dbrannon79

Young grasshopper
Joined
Oct 9, 2022
Messages
89
Reaction score
18
Location
Texas
Blue iris tools problem with new blueiris server 5.7.9.4 update
I have learned to steer clear of the updates. sometimes things break when otherwise was working fine. you can downgrade to an earlier version. the only reason to update would be if something isn't working properly.

always test out the updates on a separate PC, when running network IP cameras, you can connect to them all making a duplicate system for testing purposes.
 

fishinforfacts

Young grasshopper
Joined
Sep 6, 2019
Messages
33
Reaction score
4
Location
Warsaw, VA
I am having trouble understanding what values to put in the following line.

$UrlWU = "Your PW Station ID&format=json&units=e&apiKey=Your WU API Key*"

The station I want to connect to is

On the Weather Underground line I have set it as follows:
$UrlWUCond = "New Port Richey, FL Weather Conditions | Weather Underground Haven/KFLWINTE954"

Any help would be appreciated. Thanks.
 

fishinforfacts

Young grasshopper
Joined
Sep 6, 2019
Messages
33
Reaction score
4
Location
Warsaw, VA
In the previous post it put a link to Weather Underground, but I pasted the link to the actual station ID The station ID is KFLWINTE954. I couldn't figure out how to edit the post so am replying instead. Thanks again.
 

fishinforfacts

Young grasshopper
Joined
Sep 6, 2019
Messages
33
Reaction score
4
Location
Warsaw, VA
In my first reply when I posted the reply the posting process changed a number or things I wrote, so I am going to repost it again and hope it leaves it alone this time.

I am having trouble understanding what values to put in the following line.

$UrlWU = "Your PW Station ID&format=json&units=e&apiKey=Your WU API Key*"

In the two below items I have changed https to *

The station I want to connect to is
"****:/www.wunderground.com/dashboard/pws/KFLWINTE954"

On the Weather Underground line I have set it as follows:
"*/www.wunderground.com/weather/us/FL/Winter Haven/KFLWINTE954"

Any help would be appreciated. Thanks.
 
Joined
May 15, 2018
Messages
8
Reaction score
6
Location
BGM
@[B]fishinforfacts[/B], sorry for not responding sooner, the API key is a Key that you get from Weather Underground for your Personal Weather Station (PWA), it's one of the options available to you when you register your PWS with WU.
 

fishinforfacts

Young grasshopper
Joined
Sep 6, 2019
Messages
33
Reaction score
4
Location
Warsaw, VA
Chances are fairly high that you will have someone with a personal weather station fairly close by. :)
I hove picked a station ID but I also need to know what the weather underground API Key to fill in this line of code "
Your PW Station ID&format=json&units=e&apiKey=Your WU API Key*"
Micheal_N_Blackwell responded as follows: "the API key is a Key that you get from Weather Underground for your Personal Weather Station (PWA), it's one of the options available to you when you register your PWS with WU. " So if I don't have a PWA then I am trying to understand what to put in the code for the WU_API_Key.

Thanks
 
Top