Send Pushover notifications with pictures and hyperlinks

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,263
Reaction score
30,264
Location
USA
For the pushover email, I am using the attach trigger leading edge image from alerts list
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
789
Reaction score
781
Location
SF Bay Area
I always intended to experiment with Pushover custom sounds, so I'm giving it a shot.

Attached are a select few Blue Iris sounds converted to MP3 format as required by the pushover API.

They are easy to upload, should you want to give it a try.

The descriptions are mine.

1645404181092.png
 

Attachments

Last edited:

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,263
Reaction score
30,264
Location
USA
I saw in the help file that &ALERT_CLIP is the DB record locator for the most recent alert image’s clip for the camera, so I have been trying unsuccessfully to try to make that work with the API.

Maybe @jaydeel can work his magic to make that work?
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
789
Reaction score
781
Location
SF Bay Area
I've got no clever use for the &ALERT_CLIP macro in the pushover notification.

&ALERT_CLIP is just the database record for the clip in which the alert occurred.

Here's an illustration...

1. Output from writing alert-related macros from a camera's most recent alert to a text file (via a 'Write to a file' action)...
Code:
various alert macros for cam 'FD'...
ALERT_DB=@400613452
ALERT_PATH=FD.20220221_080000.734522.145-0.29874.0.jpg
ALERT_CLIP=@400322049
2. Output of the JSON clipstats command for alert @400613452
Code:
JSclipstats~@400613452
Array
(
    [camera] => FD
    [path] => @400322049.bvr
    [file] => FD.20220221_080000.734522.145-0.29874.0.jpg
    [offset] => 734522
    [date] => 1645459200
    [color] => 9068350
    [flags] => 1
    [plate] =>
    [res] => 1920x1080
    [msec] => 734506
    [alertmsec] => 0
    [camprofile] => 5
    [camschedule] => 1
    [camsmart] => 2
    [camzones] => 1
    [campreset] => 2
    [filesize] => 12m21s (118.4M)
    [filetype] => bvr H264 New
)
The alert @400613452 is located in clip @400322049.bvr at offset 734522.

EDIT: I believe UI3, when you use the rec=&ALERT_DB argument, uses this JSON command to extract the clip and offset to stream the alert.
 
Last edited:

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,263
Reaction score
30,264
Location
USA
Well bummer!

So the question is how is the email command able to pull this thumbnail image from the alerts, but the API cannot?
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
789
Reaction score
781
Location
SF Bay Area
I'm not clear why you think this happening when you configured the email action to attach the trigger leading edge image from alerts list.
Maybe I'm missing something? Maybe I need to see a screenshot of the email from your action.
 

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,263
Reaction score
30,264
Location
USA
After blowing up my systems with over 200,000 images LOL, the only cameras of mine now that save jpgs are the LPR cameras out of the record tab. And I have BI flush that out every 30min. The high rez image is only needed for a 3rd party plate reader, so no reason to save them any longer.

None of my other cameras are set to save jpgs. Under alerts it is database only and nothing is set to save snapshots under the Record tab.

So none of my other cameras are saving jpgs. My alerts folder is empty and my snapshots folder only has LPR jpgs, yet I get an alert image from my other cameras using the email function, whether I use the pushover generic email or send it to gmail, or even a text message.

So somehow that option is able to pull an image from the database and send it via email or text message. On a phone, the quality of that jpg is more than sufficient.

So we are either stuck with continue with the generic pushover email and get just one sound, or save hi-rez jpgs and increase the clips count in order to get different sound for different cameras.

Again for some people it might not make a difference, but for those wanting to keep clips count down, this can be an issue.

It seems like if the email function is able to pull an image without jpgs needing to be saved, so could the API function?
 
Last edited:

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
789
Reaction score
781
Location
SF Bay Area
I don't know how the email action extracts images, but we can do it using these two HTTP interface commands:
http://192.168.1.3:8600/file/clips/@400613452.bvr ... leading edge trigger image (from clip)
http://192.168.1.3:8600/thumbs/@400613452 ... database thumbnail

Unfortunately, if I understand correctly, the pushover API does not allow images to be downloaded (only uploaded), So using any of these is probably not an option.

EDIT: There might be a way to run a script to grab these images and save them to the hard drive BEFORE executing the curl action. I'll think about this.
 
Last edited:

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,263
Reaction score
30,264
Location
USA
Bummer.

I guess time to put a request in to BI about adding in the API command option the ability to check box the leading edge trigger images?

Or maybe it is not as simple as that and a lot of coding is involved?
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
789
Reaction score
781
Location
SF Bay Area
Ok, here's a possible solution
How to Create Thumbnail & Leading Edge JPEG Image Files from a Camera's Most Recent Alert

Purpose
: These Blue Iris 'Action set' actions create alert *.jpg files that may be uploaded by the Pushover API.

The files are created via these Blue Iris HTTP commands:
http://192.168.1.3:8600/thumbs/@400613452 ... database thumbnail
http://192.168.1.3:8600/file/clips/@400613452.bvr ... leading edge trigger image (from clip)

Instructions: The method may seem a bit kludgy, but it gets the job done.
It requires four, maybe five, 'Alert' tab 'On alert' actions.
In essence, it dynamically creates and executes two PowerShell scripts.

1645480366895.png

#1 is a 'Write to a file' action that creates a PowerShell script that replaces '@' character with '%40' in the URLs in the script created by action #2.
#2 is a 'Write to a file' action that creates a PowerShell script that executes the above mentioned Blue HTTP interface commands and saves the JPEGs to the hard disk.
#3 is a 'Run a program' action that executes the script in action #1.
#4 is an OPTIONAL delay if needed... so far I've had success without using a delay.
#5 is a 'Run a program' action that executes the script in action #2.

The details for actions 1,2,4 & 5 follow...
Screenshots:
1645477514194.png 1645478176323.png 1645478198558.png 1645478215855.png
Code:
Note: I've attached the code as a text file. This will make it easier to edit the path for the scripts and *.jpgs to match your system.
Code:
Action #1 - PS Script #1
File: D:\Blue Iris\Snapshots\replace_text.ps1
Parameters: $path = "D:\Blue Iris\Snapshots\grab_images.ps1"\n$word = "@"\n$replacement = "%%40"\n$text = get-content $path \n$newText = $text -replace $word,$replacement\n$newText > $path

Action #2 - PS Script #2
File: D:\Blue Iris\Snapshots\grab_images.ps1
Parameters: Invoke-WebRequest &LAN/file/clips/&ALERT_DB.bvr -OutFile "D:\Blue Iris\Snapshots\&CAM_leading_edge.jpg"\nInvoke-WebRequest &LAN/thumbs/&ALERT_DB -OutFile "D:\Blue Iris\Snapshots\&CAM_thumbnail.jpg"

Action #3 - Run script from Action #1
File: powershell.exe
Parameters: -File "D:\Blue Iris\Snapshots\replace_text.ps1"

Action #5 - Run script from Action #2
File: powershell.exe
Parameters: -File "D:\Blue Iris\Snapshots\grab_images.ps1"
BTW - the double percent entry in action #2 is not a typo... Blue Iris will interpret %40 as one of its numbered macros. A double '%%' is required to create a literal percent character.

When your camera triggers, you should see the following files
1645478820907.png


======
If you've never run PowerShell scripts on your system before...
then you may need to enable execution before the actions #3 & #5 will work.
Follow the instructions here: How to enable execution of PowerShell scripts?

=====
EDIT #1: To simplify things, you can opt to NOT include action #1 after the utility script 'replace_text.ps1' has been created the first time.
Recreating it every time has the benefit of avoiding failure of the action set should the script ever be deleted.
I've attached a copy of the utility script if you'd prefer to add it to the folder yourself, and thus avoid adding task #1 to each camera.

=====
EDIT #2 (2/22): It just dawned on me that it might be preferable to use a Blue Iris macro to store the path used for the scripts & images, as this makes the tasks easier to mange in the future, should you change drives or folders. Note that if you do this, you should not use the method in Edit #1.
I've attached rev1 of this text file 'actions_fields.rev1.txt'. It uses Blue Iris macro %900.
To create this macro, use the steps previously shown in post #73:
1. Execute this command from your browser. Replace my webserver address with yours.
http://192.168.1.3:8600/admin?macro=900&text=
2. Open 'regedit.exe'.
3. Navigate to registry key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Perspective Software\Blue Iris\Macros.
4. Double-click reg key %900 and paste in your current path, like 'D:\Blue Iris\Snapshots'.
 

Attachments

Last edited:

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,263
Reaction score
30,264
Location
USA
WOW - how in the world did you ever figure that out!

Cool stuff. Gonna try it now and see how bad I can screw it up LOL
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
789
Reaction score
781
Location
SF Bay Area
I use not-kiddin for the driveway stuff, I downloaded and use a Westminster chime for front door approaches, alarm frenzy for rear approaches and the doorbell for the doorbell camera.
I just went ahead and converted all 52 Blue Iris sounds to MP3 format.
Used Audacity, File>Export>Export Multiple w/ default settings.
 

Attachments

Last edited:

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,263
Reaction score
30,264
Location
USA
OK, I found another way to get the hi-res images out of the alerts and not lose the alert thumbnails.

If you go in periodically and delete the files in the Alerts folder and then do a repair/regenerate, it will drop the clips count down by the number of files you deleted and keeps the thumbnail images. At least it did on my computer.
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
789
Reaction score
781
Location
SF Bay Area
If you go in periodically and delete the files in the Alerts folder and then do a repair/regenerate, it will drop the clips count down by the number of files you deleted and keeps the thumbnail images. At least it did on my computer.
Which way are you saving alert JPEGs?
1. via the Trigger tab > Add to alerts list > Hi-res JPEG files;
2. via the Trigger tab > AI > Burn label mark-up to alert images
3. Both?

I’m only doing #2... as noted in post #79, I’ve confirmed your observation in this case.
 

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,263
Reaction score
30,264
Location
USA
I have tried them all in my quest for efficiency LOL. Right now I am doing #2 as I save the high res in the Record tab and BI can clear those under clips/archiving without losing anything.

It seems like a manual delete of the Alerts files results in thumbnails staying. But using the clips/archiving function to delete Alerts wipes out the thumbnails.
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
789
Reaction score
781
Location
SF Bay Area
It seems like a manual delete of the Alerts files results in thumbnails staying. But using the clips/archiving function to delete Alerts wipes out the thumbnails.
This behavior might be good to confirm with Ken… with a request to not make both approaches behave similarly in the future (i.e., handle thumbnails like the clips/archiving function).
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
789
Reaction score
781
Location
SF Bay Area
@wittaj
One more question... On the Record tab, are you currently saving JPEGs 'When triggered' ... or 'When alerted'.
I've been doing all my testing with later.
 

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,263
Reaction score
30,264
Location
USA
I do it when triggered. And it does one jpg per triggered event.
 
Top