Announcement

Collapse
No announcement yet.

Passing parameters to events / preventing event duplication?

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

    Passing parameters to events / preventing event duplication?

    Is it possible to pass a parameter to an event?

    My scenario:

    I have lots of events across my event groups and events - many of them (but not all), I want to send me a notification via e-mail.

    I can do that....but then if I change my e-mail address (e.g. have my wife start receiving them or change account, etc....) I have to change it in dozens or hundreds of events.

    In the events I want to notify me, I could just say "run the event "notify me"" and pass in a string (or a few strings) to denote the e-mail address, subject, and/or message body.

    I can see LOTS of uses for this to prevent event duplication for various states.

    Doable? Other ways to accomplish what I'm looking at? I don't think group actions will work because not all events across all groups will have the exact same e-mail, for example.

    #2
    I do this with a simple script. All email/text events call the same script and pass it a parameter that describes the reason. In my example, it's to tell me that the alarm has been disarmed (usually because the pet sitter has come while we are away).

    The basic components of the script are:
    Code:
        Public Sub Main(ByVal strSubject As String)
    
            Dim strFrom As String = "aaaaaaa@gmail.com"
            Dim strTo As String = "nnnnnnnnnn@tmomail.net"
            Dim strMessage As String = "$time $date"
    
            hs.SendEmail(strTo, strFrom, "", "", strSubject, strMessage, "")
    
        End Sub
    In this example, I send a simple phrase to indicate what prompted the message and the body of the message contains the time and date.
    Attached Files
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

    Comment


      #3
      Exactly how I do it. One script for all emails, referenced by many events.

      tenholde
      tenholde

      Comment


        #4
        Originally posted by Uncle Michael View Post
        I do this with a simple script. All email/text events call the same script and pass it a parameter that describes the reason. In my example, it's to tell me that the alarm has been disarmed (usually because the pet sitter has come while we are away).

        The basic components of the script are:
        Code:
            Public Sub Main(ByVal strSubject As String)
        
                Dim strFrom As String = "aaaaaaa@gmail.com"
                Dim strTo As String = "nnnnnnnnnn@tmomail.net"
                Dim strMessage As String = "$time $date"
        
                hs.SendEmail(strTo, strFrom, "", "", strSubject, strMessage, "")
        
            End Sub
        In this example, I send a simple phrase to indicate what prompted the message and the body of the message contains the time and date.

        I am following with great interest as I have dozens of email/Pushover/Pushbullet events that would benefit from this method.

        This looks like a great script. Could you please explain this in a bit more detail. In the example you've shown I don't see how the variable strSubject gets loaded with the string for User3 for instance.

        Comment


          #5
          Originally posted by Kitar View Post
          Could you please explain this in a bit more detail. In the example you've shown I don't see how the variable 'strSubject' gets loaded with the string for User3 for instance.
          The value of strSubject is specified in the event. It's in the 'Parameters' field. So, when the event is triggered, it runs the script and passes whatever is in that field to it.

          My event to warn me that the alarm has been tripped looks like this:
          Attached Files
          Mike____________________________________________________________ __________________
          HS3 Pro Edition 3.0.0.548, NUC i3

          HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

          Comment


            #6
            Originally posted by Uncle Michael View Post
            I do this with a simple script. All email/text events call the same script and pass it a parameter that describes the reason. In my example, it's to tell me that the alarm has been disarmed (usually because the pet sitter has come while we are away).

            The basic components of the script are:
            Code:
                Public Sub Main(ByVal strSubject As String)
            
                    Dim strFrom As String = "aaaaaaa@gmail.com"
                    Dim strTo As String = "nnnnnnnnnn@tmomail.net"
                    Dim strMessage As String = "$time $date"
            
                    hs.SendEmail(strTo, strFrom, "", "", strSubject, strMessage, "")
            
                End Sub
            In this example, I send a simple phrase to indicate what prompted the message and the body of the message contains the time and date.
            Thanks much for this. I don't use any scripts but this will probably be my first. Very useful. I just changed from yahoo mail to gmail so I had to edit a bunch of events. This would have made it easy.

            Comment

            Working...
            X