Announcement

Collapse
No announcement yet.

Sending an Email or Text of a Snapshot

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

    #16
    that's a good idea. Would the full http path device string (status) be a hyperlink to click and open the image full size in another window?

    Comment


      #17
      Originally posted by will40 View Post
      that's a good idea. Would the full http path device string (status) be a hyperlink to click and open the image full size in another window?
      The first and foremost important hurdle is that a webserver (HS in this case), can only serve content from a specific root path, this is a protection against hacking. So for HS it is <hs root>/html and all its subdirectories. So if the intent of the string value of the snapshot feature is to do a webserver retrieval it should be formed as a relative URI with either HTTP://<ip address>:<ip port>/path or file:/// etc or it is a full path on your disk, in which case it would be c:\xxx\xxx\xxx but that cannot be served via a webserver in this format AND (baring some VPN into your PC or shared directories (big no-no)) that file cannot be retrieved from another host.

      And therein lies the conundrum of what to put in the string value of the Snapshot feature.

      Comment


        #18
        Originally posted by dcorsus View Post

        I see, if you don't want to (continue) to go the script route , perhaps you can try (in the attachment section)

        C:\Program Files (x86)\HomeSeer HS4\html$$DTR:460:

        edit: not sure this will work, but worth suggesting/trying

        I tried that but I am using Linux and tried instead of C:\Program Files (x86)\HomeSeer HS4\html$$DTR:460:

        I used /usr/local/HomeSeer/html/Ring/$$DTR:460:

        and it doesn't work. Any suggestions?

        Comment


          #19
          Originally posted by will40 View Post
          you can save this script.vb and run it from your event if your image path is the same

          Code:
          Sub Main(Parm As Object)
          
          Dim RingImage
          RingImage = hs.devicestring (xxxx)'where x is your HS RING Snapshot device ref#
          
          hs.SendEmail("yourto@email","yourfrom@email","","","your subject","This is RING Motion Image taken on " &now(),"C:\Program Files (x86)\HomeSeer HS4\html" & RingImage)
          
          End Sub​

          script works for me (Windows 10) and your copy looks ok and sounds like you got the correct device string.

          I just tried using the device string as a replacement variable for the email attachment and cant get it to work for me everyway I try.



          I am using Linux for HS4 so the location of the snapshot is at: /usr/local/HomeSeer/html/Ring

          I tried inserting that where you have C:\Program Files (x86)\HomeSeer HS4\html and can't seem to put it there.​

          Comment


            #20
            I am not a Linux platform guy but maybe try the following script a different way. Remember the plug in's device status (string) 460 contains the remainder of the string after html. ex: (\ring\snapshots\snapshot_123456_03-19-2023_09-17-18.jpg)

            Code:
            Sub Main(Parm As Object)
            
            Dim RingImage
            Dim EmailFrom
            Dim EmailTo
            Dim Subject
            Dim Body
            Dim Attach
            
            RingImage = hs.devicestring (460)
            
            EmailFrom = "xxxxx@comcast.net"
            EmailTo = "xxxxxx@gmail.com"
            Subject = "Ring Image"
            Body = "This is RING Motion Image taken on " &now()
            Attach = "\usr\local\HomeSeer\html" & RingImage
            
            hs.SendEmail(EmailFrom,EmailTo,"","",Subject,Body,Attach)
            
            End Sub​

            Comment


              #21
              Originally posted by dcorsus View Post

              The first and foremost important hurdle is that a webserver (HS in this case), can only serve content from a specific root path, this is a protection against hacking. So for HS it is <hs root>/html and all its subdirectories. So if the intent of the string value of the snapshot feature is to do a webserver retrieval it should be formed as a relative URI with either HTTP://<ip address>:<ip port>/path or file:/// etc or it is a full path on your disk, in which case it would be c:\xxx\xxx\xxx but that cannot be served via a webserver in this format AND (baring some VPN into your PC or shared directories (big no-no)) that file cannot be retrieved from another host.

              And therein lies the conundrum of what to put in the string value of the Snapshot feature.
              yup I got ya. Its would be one of those 'will work for some but not all' methods. Probably best to leave as is then?

              Another solution to the script above, if its an issue depending on the user's OS, would be to cobble up a script during the RING motion event to copy the RING image captured to another folder, email the only file in that folder, then delete it and empty that folder afterwards for the next image. I do this with my security camera videos and it works.

              Comment


                #22
                Originally posted by will40 View Post
                I am not a Linux platform guy but maybe try the following script a different way. Remember the plug in's device status (string) 460 contains the remainder of the string after html. ex: (\ring\snapshots\snapshot_123456_03-19-2023_09-17-18.jpg)

                Code:
                Sub Main(Parm As Object)
                
                Dim RingImage
                Dim EmailFrom
                Dim EmailTo
                Dim Subject
                Dim Body
                Dim Attach
                
                RingImage = hs.devicestring (460)
                
                EmailFrom = "xxxxx@comcast.net"
                EmailTo = "xxxxxx@gmail.com"
                Subject = "Ring Image"
                Body = "This is RING Motion Image taken on " &now()
                Attach = "\usr\local\HomeSeer\html" & RingImage
                
                hs.SendEmail(EmailFrom,EmailTo,"","",Subject,Body,Attach)
                
                End Sub​
                No that doesn't seem to work. I think in Linux the \ has to be the other way, I tried changing them, but it still doesn't work.

                Also, when I use the following in the message area of the email or text:

                http://xxxxx.ddns.net:6161$$DTR:460:

                The link shows up but it will display the previous string not the current snapshot.

                What would be ideal is to just show the snapshot that was just taken in the text.

                Any ideas or suggestions?

                Comment


                  #23
                  Originally posted by will40 View Post
                  yup I got ya. Its would be one of those 'will work for some but not all' methods. Probably best to leave as is then?
                  Might make it an settable option, but the more I think about it, maybe the full path is a smidge better. If you would have to use it in some type of script anyway and therefore you can easily transform one into the other.

                  Originally posted by will40 View Post
                  Another solution to the script above, if its an issue depending on the user's OS, would be to cobble up a script during the RING motion event to copy the RING image captured to another folder, email the only file in that folder, then delete it and empty that folder afterwards for the next image. I do this with my security camera videos and it works.
                  So the trick here is to use either:
                  - Environment.CurrentDirectory
                  or
                  - hs.GetAppPath

                  Secondly Windows uses backslashes (\) whereas Linux uses forward slashes (/) in their pathname. Linux does NOT accept backslashes but Windows doesn't care so build your pathname using forward slashes (/). ALSO Linux file names are case sensitive so make sure you respect those.

                  So use the above functions in your .vb script to form the right "attach" path.​

                  Comment


                    #24
                    have you tried the script placing the current RING image as the "Attach" variable above to determine if the script is all wrong for Linux? Sorry I can't help if its a Linux thing.

                    Attach = "/usr/local/HomeSeer/html/ring/snapshots/snapshot_123456_03-19-2023_09-17-18.jpg"

                    This way you can determine if your device 480 has the correct Linux format for the string?

                    Comment


                      #25
                      No I get an error message:



                      3/19/2023 11:15:54 AM
                      HomeSeer
                      Error
                      Compiling script (1)FrontDoorSnapshot.vb: 'End' statement not valid.

                      3/19/2023 11:15:54 AM
                      HomeSeer
                      Error
                      Compiling script (1)FrontDoorSnapshot.vb: 'End Sub' expected.


                      Comment


                        #26
                        Originally posted by skozin View Post
                        No I get an error message:



                        3/19/2023 11:15:54 AM
                        HomeSeer
                        Error
                        Compiling script (1)FrontDoorSnapshot.vb: 'End' statement not valid.

                        3/19/2023 11:15:54 AM
                        HomeSeer
                        Error
                        Compiling script (1)FrontDoorSnapshot.vb: 'End Sub' expected.


                        Looks like a typo somewhere. Suggest you always post the source code and the error combined so other can help spot them.
                        I see an &now() , not sure but shouldn't there be a space like & now(). Suspect the error might be a typo somewhere else in your script, perhaps a " forgotten

                        Comment


                          #27
                          if there is still a question of your file path try replacing the Attach variable with

                          Code:
                          Attach = hs.GetAppPath & "/html" & RingImage
                          Yes, post your script code. Someone will chime in with the correct syntax. The email script above is a very simple script. It should work.

                          Comment


                            #28
                            Thanks to Jon00 and Will40, I think I have it now. What needed to be done is to create 2 scripts: One is the following:
                            (This is for Linux, Windows chang the "/" to "")

                            Script 1

                            Imports System.IO


                            Sub Main(ByVal Parm As Object)
                            Dim FN As String = ""
                            Dim FD As String = ""
                            Dim NFN As String = ""
                            Dim NFD As Date
                            Dim Directory As String = hs.GetAppPath & "/html/Ring/snapshots"

                            FN = Dir(Directory & "/*.jpg")
                            Do While FN <> ""
                            FD = FileDateTime(Directory & "/" & FN)
                            If FD > NFD Then
                            NFN = FN
                            NFD = FD
                            End If
                            FN = Dir
                            Loop
                            My.Computer.FileSystem.CopyFile(Directory & "/" & NFN, Directory & "/latest.jpg", overwrite:=True)

                            End Sub​


                            Then create the email script:

                            Script 2

                            Sub Main(ByVal Parm As Object)
                            Dim RingImage As String = ""
                            Dim EmailFrom As String = ""
                            Dim EmailTo As String = ""
                            Dim Subject As String = ""
                            Dim Body As String = ""
                            Dim Attach As String = ""


                            EmailTo = "xxxx@tmomail.net"
                            EmailFrom = "xxxx@comcast.net"
                            Subject = "Ring Image"
                            Body = "Taken on " &now()
                            Attach = hs.GetAppPath & "/html/Ring/snapshots/latest.jpg"
                            hs.writelog("Attach",Attach)

                            hs.SendEmail(EmailTo, EmailFrom, "", "", Subject, Body, Attach)

                            End Sub

                            The 1st script will copy the new image over to the name "latest.jpg". Then I can run the 2nd script to then send the email with the attachment. This can be done on one event using a 5 second delay:

                            Event Picture Taken and Send Text
                            Action Event 1 (Picture Taken)
                            Run 1st script (Imports System IO)
                            wait 5 seconds
                            Event Send Text Message with Picture
                            Run 2nd script (Script #2)

                            Hope this helps.​

                            Comment


                              #29
                              Originally posted by skozin View Post
                              Thanks to Jon00 and Will40, I think I have it now. What needed to be done is to create 2 scripts: One is the following:
                              (This is for Linux, Windows chang the "/" to "")

                              Script 1

                              Imports System.IO


                              Sub Main(ByVal Parm As Object)
                              Dim FN As String = ""
                              Dim FD As String = ""
                              Dim NFN As String = ""
                              Dim NFD As Date
                              Dim Directory As String = hs.GetAppPath & "/html/Ring/snapshots"

                              FN = Dir(Directory & "/*.jpg")
                              Do While FN <> ""
                              FD = FileDateTime(Directory & "/" & FN)
                              If FD > NFD Then
                              NFN = FN
                              NFD = FD
                              End If
                              FN = Dir
                              Loop
                              My.Computer.FileSystem.CopyFile(Directory & "/" & NFN, Directory & "/latest.jpg", overwrite:=True)

                              End Sub​


                              Then create the email script:

                              Script 2

                              Sub Main(ByVal Parm As Object)
                              Dim RingImage As String = ""
                              Dim EmailFrom As String = ""
                              Dim EmailTo As String = ""
                              Dim Subject As String = ""
                              Dim Body As String = ""
                              Dim Attach As String = ""


                              EmailTo = "xxxx@tmomail.net"
                              EmailFrom = "xxxx@comcast.net"
                              Subject = "Ring Image"
                              Body = "Taken on " &now()
                              Attach = hs.GetAppPath & "/html/Ring/snapshots/latest.jpg"
                              hs.writelog("Attach",Attach)

                              hs.SendEmail(EmailTo, EmailFrom, "", "", Subject, Body, Attach)

                              End Sub

                              The 1st script will copy the new image over to the name "latest.jpg". Then I can run the 2nd script to then send the email with the attachment. This can be done on one event using a 5 second delay:

                              Event Picture Taken and Send Text
                              Action Event 1 (Picture Taken)
                              Run 1st script (Imports System IO)
                              wait 5 seconds
                              Event Send Text Message with Picture
                              Run 2nd script (Script #2)

                              Hope this helps.​
                              Happy to see you figured it out but why a script to copy/rename a file and not use the feature.stringValue and avoid having 2 scripts?

                              Comment


                                #30
                                Because I don't know scripting well and I don't know how to use stringvalue in a script.

                                Comment

                                Working...
                                X