Powershell Script to Send Pushover Notifications with a Camera's or Cam Group's Current Image

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
I've developed a Powershell script (pushover_snapshot.ps1) that can send a Pushover notification with a current camera snapshot, or current video stream image. The second method can also send camera group images. Additionally, all attachments can be resized before sending.

When sending Blue Iris snapshots, the database memo is set to make it clear that the snapshot was created by the script.

When sending a current stream image from a dual-stream camera, the default is a sub stream image. You have the option of grabbing a main stream image instead.

The resize feature enables shrinking large attachments (exceeding 2.5MB) that would otherwise result in the rejection of the notification by the Pushover API.

The script accepts a variety of user customizations via a separate Powershell 'user_settings' file.

The script also automatically logs its activity to a CSV file.

Here's a screenshot of all arguments available in the script:
pushover_snapshot.ps1 -Help
help_guide.png

HOW TO GUIDE...

STEP #1:

Install the script and its companion 'user settings file'
  1. Extract all the files from the attached zip file to your desktop, or scripts folder.
  2. Please note that the folder used must be in your PC's environment path.
  3. Create a working folder for this script - it will be used to process the attachments files; to hold the script's log file, etc.
  4. To use the folder, you must edit a user setting $app_path in the user-settings script file (see Step #2)
NOTE: If you've never used PowerShell on your Blue Iris PC, you may first to need to change its default security policy.​
Open PowerShell in Administrator mode, and type the following, then hit the Enter key:​
Set-ExecutionPolicy RemoteSigned
(click here for a nice beginner's tutorial to using PowerShell).​

STEP #2:

Edit the user settings file
  1. The user settings file is named 'pushover_snapshot_user_settings.ps1'?
  2. Open the file in a code text editor (I use Notepad++)
  3. Edit the REQUIRED variables in the USER SETTINGS section (see screenshot)
  4. Ignore the remaining settings for now. They provide customizations that you may want to explore later.
reqd_user_settings.png

STEP #3:

Test the script from the console
  1. Open an Admin PowerShell window, or Powershell-ISE window
  2. Select and copy each of the the following commands and paste it into the console (one at a time)
    pushover_snapshot.ps1 -Msg "current snapshot" -CamName "DW1"
    pushover_snapshot.ps1 -Msg "current stream grab" -CamName "DW1" -Grab -Mainstream
    pushover_snapshot.ps1 -Msg "current stream grab" -CamName "Index" -Grab
  3. Edit 'DW1' to match the short name of one of your cameras
  4. Hit the Enter key.
The response should look like following screenshot​
output_example_1.png
You should also receive your first Pushover notifications from the script, like these examples:​
device_pushover_notifications_1.jpg device_pushover_notifications_2.jpg
And the first command in #2 above should show a new entry in the cliplist, like this​
cliplist snapshot.png
NOTE: The script can also be executed from an Admin cmd.exe window using a command like​
powershell.exe "C:\ps_scripts\{scriptname}.ps1 args"

STEP #4:

Test on a on a camera Preset
  1. Click 'Camera settings' > 'PTZ/Control' tab
  2. Click 'Edit Presets..." to open the preset editor
  3. Create a new 'Run a program' action, and configure it as shown in the following screenshot
action_example_1.png
The code for the 'Parameters' field is like the following:​
"C:\ps_scripts\pushover_snapshot.ps1" -Msg """current image <b>&CAM</b>""" -CamName &CAM
"C:\ps_scripts\pushover_snapshot.ps1" -Msg """current image <b>&CAM</b>""" -CamName &CAM -Grab -Mainstream
Please note that the triple double quotes (""") in the -Msg parameter are ESSENTIAL.

Script Zip File
 

Attachments

Last edited:

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
Usage Examples:

Send camera / cam group image notifications on a schedule

In the Blue Iris console...​
  1. Select a Camera
  2. Click Camera settings > PTZ/Control > Edit Presets
    Set up a preset to execute the pushover_snapshot.ps1 script (see screenshot below)
  3. Click Camera settings > Schedule > Events schedule
    Setup an event to execute the preset in #2 (see screenshot below)
Screenshot - Step 2​
preset_setup.png
Screenshot - Step3​
event_schedule_setup.png
 
Last edited:

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
In post#2, I probably should have given a few use cases of how this script might be useful.

To send notifications...

... showing the lawn - a few minutes after the sprinklers should have started.

To confirm that nothing is amiss with my irrigation system - like a specific sprinkler head is malfunctioning or leaking

... of the house exterior - after dusk, and after dawn.
To confirm that the entry lights are on or off.

... on demand, using a camera preset from a device.
To share a current interesting or emergency image to multiple devices (e.g. all family members) via a single action

With the first & third you can include a UI3 link in the message to quickly view the camera stream.
 
Last edited:

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
As of update 5.8.0.9 (more details), Ken has add a new macro to Blue Iris, &IMAGE_PATH

post_#4_screenshot_1.png


This new macro can be used to send Pushover notifications with a CURRENT image of the camera.

For example, try the following in a Blue Iris 'Run a program' Action:

post_#4_screenshot_2.png


Here's the code for the 'Parameters' field:
Code:
https://api.pushover.net/1/messages.json -s --form-string "token=YOUR_APP_TOKEN_HERE" --form-string  "user=YOUR_USER_KEY_HERE" --form-string "message=<b>&CAM</b> current image" --form-string "html=1" -F "attachment=@&IMAGE_PATH"

This new macro is simpler to use, though less flexible, than the script in post #1.

For example, when using the macro instead of the script, you cannot:
  • send a cam group image
  • choose between sub- and main-stream image
  • resize an image that is too large for the Pushover API
  • log send events
 
Last edited:
Top