Announcement

Collapse
No announcement yet.

Sending an Email or Text of a Snapshot

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • windracer
    replied
    Originally posted by windracer View Post
    In case anyone is interested still, I got this working (e-mail alerts for motion with the snapshot attached). Used will40's script as a starting point with some minor tweaks to allow for parameters.

    Next step is to only send the notification when the alarm is in a certain state (i.e., armed away) and also see if I can replicate this in an HSBuddy push notification.
    Continuing to refine this, now that HSBuddy supports Ring cameras, I can send a push notification with snapshot when motion occurs in a certain alarm state. This event below is sending an e-mail and the push notification, but I may turn off the e-mail part once I do more testing.

    Click image for larger version

Name:	image.png
Views:	94
Size:	98.3 KB
ID:	1621295
    HSBuddy push notification on my watch:

    Click image for larger version

Name:	image.png
Views:	56
Size:	49.4 KB
ID:	1621296

    Very cool.

    Leave a comment:


  • will40
    replied
    nice job windracer works for me!

    Leave a comment:


  • windracer
    replied
    In case anyone is interested still, I got this working (e-mail alerts for motion with the snapshot attached). Used will40's script as a starting point with some minor tweaks to allow for parameters. So it looks like this:

    Code:
    ' send e-mail with snapshot attachment for a Ring camera motion event
    '
    ' parameters: device ID of the camera's snapshot feature and the name of the camera
    ' ex. 921,dining room
    
    Sub Main(ByVal Parms as String)
    
    Dim logName = "JCR script testing" ' set log type for HS log
    
    ' script parameters
    Dim ParmArray() as String
    ParmArray = Parms.tostring.split(",")
    Dim devID as Double = CDbl(ParmArray(0)) ' ID of the camera's snapshot device (for filename)
    Dim devName as String = ParmArray(1) ' camera name (to use in e-mail)
    Dim RingImage = hs.devicestring (devID) ' path to the snapshot
    
    ' e-mail variables
    Dim EmailFrom = "<from address>"
    Dim EmailTo = "<to address>"
    Dim Subject = "[Ring] Motion detected - " & devName
    Dim Body = "Motion was detected by the " & devName & " Ring camera at " & now()
    Dim Attach = hs.GetAppPath & "/html/" & RingImage
    
    hs.writelog(logName," ID: " & devID & " / Name: " & devName & " / Path: " & Attach)
    hs.SendEmail(EmailTo, EmailFrom, "", "", Subject, Body, Attach)
    
    End Sub
    ​
    Notice in the original script, I believe the EmailTo and EmailFrom parameters in hs.SendEmail were reversed (I used this as a reference). Then, my simple test event looks like this. The key was to use "had it value set or changed." I used just "changed" initially and it wasn't working then I noticed dcorsus sample event above and switched to that trigger and it started working.

    Click image for larger version

Name:	image.png
Views:	166
Size:	56.7 KB
ID:	1613005

    The first parameter is the device ID of the camera's snapshot feature and the second is the name of the camera to use in the e-mail alert. The resulting e-mail has the snapshot attached:

    ​​Click image for larger version

Name:	image.png
Views:	86
Size:	68.3 KB
ID:	1613006
    Next step is to only send the notification when the alarm is in a certain state (i.e., armed away) and also see if I can replicate this in an HSBuddy push notification.

    Leave a comment:


  • dcorsus
    replied
    Originally posted by skozin View Post

    Hope that helps
    Not really, logs do help


    Leave a comment:


  • skozin
    replied
    Sorry Dirk, updated to 1.0.0.26 and still the same. Went outside @ 9:06:49pm and the event ran but still showed the previous timestamp: Ring/snapshots/03-24-2023_21-05-16_motion_16046093_7214299516780206093.jpg . It was the wrong snapshot. The file in the Ring/snapshots folder is still 3-24-2023_21-05-16, so it is not updating to the latest snapshot.

    Hope that helps

    Leave a comment:


  • dcorsus
    replied
    Well you are fighting multiple issues. Leave the event as you had it changed per my recommendation. I just posted v26, install that and try again.
    The issues will hopefully, mostly be fixed, but during my testing, I had one case where it took 20 seconds for the snapshot to be available for download, that means borderline fail (10 retries with 2 seconds in between).

    NC-Lou I made a minor change to recognize a car cam. Not sure it will work but recommend you upgrade to v26 and report back.

    Leave a comment:


  • skozin
    replied
    Ok I tried that and I walked up to my front door and the text gets sent but no picture and in my log the timestamp is 1/1/1969. So I went to the device page and clicked take snapshot to update the string. That string shows 5:19pm. Then I went to my front door and walked in front of the camera at 5:21pm and it sent me the picture that I manually took @ 5:19pm so it is not updating the string with the correct image. How do I know. The picture @ 5:19pm had nobody in the image, @5:21pm I am in the image according to my Ring app. Also, I just looked in the snapshots folder and the file is 17-19-25 not 17-21-00.

    Leave a comment:


  • dcorsus
    replied
    skozin

    Almost , this is how your event should look like

    Attached Files

    Leave a comment:


  • skozin
    replied
    Definitely mud!!!

    So say I try your 1st trigger:

    Trigger: when snapshot feature string changes
    ONLY action: send email or run your script. None of the taking of snapshots or waiting, the snapshot is available that's why the feature status was changed and you can safely email it.​ Click image for larger version

Name:	Untitled.png
Views:	125
Size:	83.2 KB
ID:	1600224

    But the problem is the value of the string never changes it is always at 1000. Am I using the correct Device? Because it is not working. Click image for larger version

Name:	11Untitled.png
Views:	110
Size:	106.1 KB
ID:	1600225

    Leave a comment:


  • dcorsus
    replied
    Originally posted by skozin View Post
    So it's been a couple of days since and I just updated to 1.0.23 and still having problems with taking a snapshot and sending a picture.

    I just want to let you know about the snapshot issue I am still having with my event. For some reason when the front door camera detects motion, It will take a snapshot and then send an email. The result is:
    3/24/2023 9:51:43 AM
    Script
    Attach
    /usr/local/HomeSeer/html/Ring/snapshots/01-01-1969_00-00-00__16046093_.jpg

    Which will be a blank picture. Also on the device page there is no picture just an icon. Once in a while it will send the picture with the correct time/date, but more not.


    Any ideas?​

    Here are my events and scripts: Click image for larger version

Name:	1Untitled.png
Views:	149
Size:	100.9 KB
ID:	1600209
    Click image for larger version

Name:	2Untitled.png
Views:	108
Size:	77.0 KB
ID:	1600210

    Click image for larger version

Name:	2aUntitled.png
Views:	110
Size:	79.5 KB
ID:	1600211Click image for larger version

Name:	3Untitled.png
Views:	110
Size:	104.3 KB
ID:	1600212

    Hope this helps. I just turned on debugging mode and I will PM the log.

    Thanks,
    Steve
    As I wrote before, you cannot use the motion state to trigger this event, the snapshot availability doesn't happen at the same time as when the motion event is received, it lags because the PI needs to retrieve that snapshot.

    Therefore you need to simplify this event.
    Trigger: when snapshot feature string changes
    ONLY action: send email or run your script. None of the taking of snapshots or waiting, the snapshot is available that's why the feature status was changed and you can safely email it.

    I'm still seeing very inconsistent behavior with these cameras but that doesn't invalidate what I wrote above. If you see that the camera does not generate a snapshot at all, I don't think adding actions to "take a snapshot when motion" will solve that as the PI already does that, but you can try that.
    That means you could have an independent event that triggers when motion with ONLY action to take a snapshot. The two events cannot be linked, they occur separate in time and have different triggers.

    Now to make it more muddy, say you only want to email snapshots when there is motion and NOT when you manually trigger taking a snapshot, in that case you can add a condition to the first described event and it would become:
    Trigger when the snapshot feature changes value AND (note this is a condition NOT a trigger) motion feature state <> no-motion Then send email.

    Clear as mud?

    Leave a comment:


  • skozin
    replied
    So it's been a couple of days since and I just updated to 1.0.23 and still having problems with taking a snapshot and sending a picture.

    I just want to let you know about the snapshot issue I am still having with my event. For some reason when the front door camera detects motion, It will take a snapshot and then send an email. The result is:
    3/24/2023 9:51:43 AM
    Script
    Attach
    /usr/local/HomeSeer/html/Ring/snapshots/01-01-1969_00-00-00__16046093_.jpg

    Which will be a blank picture. Also on the device page there is no picture just an icon. Once in a while it will send the picture with the correct time/date, but more not.


    Any ideas?​

    Here are my events and scripts: Click image for larger version

Name:	1Untitled.png
Views:	149
Size:	100.9 KB
ID:	1600209
    Click image for larger version

Name:	2Untitled.png
Views:	108
Size:	77.0 KB
ID:	1600210

    Click image for larger version

Name:	2aUntitled.png
Views:	110
Size:	79.5 KB
ID:	1600211Click image for larger version

Name:	3Untitled.png
Views:	110
Size:	104.3 KB
ID:	1600212

    Hope this helps. I just turned on debugging mode and I will PM the log.

    Thanks,
    Steve

    Leave a comment:


  • skozin
    replied
    Ok no problem. I thought I was going crazy either running the event or clicking the snap picture button on the web page and it wasn't updating to the correct date/time stamp every time. Thanks for your assistance.

    Regards,
    Steve

    Leave a comment:


  • dcorsus
    replied
    Originally posted by skozin View Post
    I think there is an issue running the 1st event. If I trigger the snapshot it doesn't update the date/time on the device page. What I did to try to rectify the problem was to take the snapshot, wait 5 seconds then take another snapshot. Then I ran the 2nd event a few seconds later. Can you see if the same thing happens to you on your end?
    I think you better wait for a few more days till I release this next version. I don't think I had the snapshots "under control" in the version you have but I made a lot of progress understanding how things work in this undocumented API.

    Leave a comment:


  • skozin
    replied
    I think there is an issue running the 1st event. If I trigger the snapshot it doesn't update the date/time on the device page. What I did to try to rectify the problem was to take the snapshot, wait 5 seconds then take another snapshot. Then I ran the 2nd event a few seconds later. Can you see if the same thing happens to you on your end?


    Click image for larger version

Name:	Untitled.png
Views:	93
Size:	93.6 KB
ID:	1599567
    Click image for larger version

Name:	1Untitled.png
Views:	79
Size:	83.2 KB
ID:	1599568Click image for larger version

Name:	2Untitled.png
Views:	88
Size:	102.5 KB
ID:	1599569

    Leave a comment:


  • dcorsus
    replied
    The correct trigger is "This device just had its Value Set or Changed" and ONLY for the snapshot feature.
    edit: I just looked at the rest of the event, you are taking a snapshot when the snapshot changes, that indeed would be an endless loop. When you have a motion or ring event, AND you have set notifications, the PI (at least the version I'm about to release) will take a snapshot for each and any event, so NO need for you to take a snapshot when there is motion or ringing.
    Now if that's what you want to do, you need to make at least 2 events:
    1. first event that takes a snapshot on some trigger
    2. second event triggers when the snapshot string changes and composes and sends an email

    Leave a comment:

Working...
X