Announcement

Collapse
No announcement yet.

How do I get alert information from a script with Alert#:Trigger#

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

    How do I get alert information from a script with Alert#:Trigger#

    My apologies if this was covered somewhere but I could not locate anything on the boards about this.

    It would appear that the alert trigger script option will run the sub Main() with a single parameter of a packed string with two pieces of information separated by a semicolon. No custom parameters can be passed.

    My question... How can I retrieve all of the alert information from a scrip with the supplied information (Alert#:Trigger#)? I don't want to reply on HS3 devices and would like to be able to access all of the #variable# replacement values.

    Thank you!
    HS4, Insteon, Z-wave, USB-UIRT, Harmony Hubs, Google Hub/Chromecasts/Speakers, Foscam & Amcrest cameras, EZVIZ DB1 doorbell
    Plugins: BLLAN, BLOccupied, BLUSBUIRT, Chromecast, Harmony Hub, Insteon, Jon00 Homeseer/Echo Skill Helper, Harmony Hub, Jon00 DB Charting, MediaController, NetCAM, PHLocation2, Pushover 3P, weatherXML, Z-wave

    #2
    I won't be home until late this evening. But will look this up for you.
    I think the light at the end of the tunnel is me getting back to a more normal schedule.

    I may need to add some more public functions to get exactly what you want.
    --
    Jeff Farmer
    HS 3, HSPhone
    My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
    Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

    Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

    Comment


      #3
      When you set the alert trigger to run a script it sends the alert id and trigger id. With the alert id, the script can call a function in the plugin.
      The variable sText is the text that you put the variables in. You can use any logic that you want to build the text.

      Once you have your text ready the script calls the public function replaceVariablesAlert.
      The params are alert ID, replace text, triggered.

      sVar will be available after the function call to use it in emails, speaking, etc.

      Since this is expected to be called by a trigger, it is expected that there is an alert to use to replace the variables. Calling the function when there are no alerts or with an invalid alerted will put some error messages in your log.

      Hope this helps with what you are wanting to do.

      PHP Code:
       Sub Main(Optional ByVal Params As String "")
          
      Dim aParams As Array
          
      Dim sVar as string
          Dim sText 
      "This is an alert #alertTitle#."
          
      aParams Params.Split(":")
       
          
      hs.WriteLog("Test","Param 1 = " aParams(0))
          
      hs.WriteLog("Test","Param 2 = " aParams(1))

           
      sVar hs.PluginFunction("weatherXML","","replaceVariablesAlert", new Object(){aParams(0),sTextaParams(1)})
           
            
      hs.WriteLog("Test"sVar)
       
      End Sub 
      --
      Jeff Farmer
      HS 3, HSPhone
      My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
      Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

      Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

      Comment


        #4
        Sorry I didn't reply right away. I didn't get an email notification. I think this will work perfectly. This could help me get around the issue I am having in this thread if it is not able to be resolved:

        http://forums.homeseer.com/showthread.php?p=1253801

        I could use your code snipped to have just one trigger and program a script to send just an email, or an email and a shorter text, depending on the alert level. I'd still be interested in figuring out why my setup outlined in the thread above is not working.

        Much thanks!
        HS4, Insteon, Z-wave, USB-UIRT, Harmony Hubs, Google Hub/Chromecasts/Speakers, Foscam & Amcrest cameras, EZVIZ DB1 doorbell
        Plugins: BLLAN, BLOccupied, BLUSBUIRT, Chromecast, Harmony Hub, Insteon, Jon00 Homeseer/Echo Skill Helper, Harmony Hub, Jon00 DB Charting, MediaController, NetCAM, PHLocation2, Pushover 3P, weatherXML, Z-wave

        Comment


          #5
          I should be able to start working on my plugins again. The position change at work took a lot more time then I had thought it would.

          But for now, I would suggest using the script.
          I have a pretty big list of things to work on at this point.
          --
          Jeff Farmer
          HS 3, HSPhone
          My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
          Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

          Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

          Comment


            #6
            I used the Alert Triggers to run a script, hoping to utilize the alert global variables. The problem I was having is that the global variables were not set at the same time the weather trigger occurred.

            As a workaround, I trigger the script based on the value change of the alert device. The global alert variables, which have all the information needed, are available at that time.

            Jeff, the request I would have for the future is to ensure the alert global variables have been set before issuing the alert trigger.

            Thx,
            -ron

            Comment


              #7
              I've added your request to my to do list.
              --
              Jeff Farmer
              HS 3, HSPhone
              My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
              Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

              Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

              Comment

              Working...
              X