Announcement

Collapse
No announcement yet.

Best way to determine which device or trigger group triggers an event

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

    Best way to determine which device or trigger group triggers an event

    Hi,

    I have a custom vb.net script set to run when certain devices change. The script needs to know which device(s) caused the script to run. Right now I'm loosely determining this by seeing how much time has elapsed between the script running and the devices' last change value. Unfortunately, the script doesn't seem to always run immediately after the device changes. I've currently recorded it taking anywhere from 0-12 seconds. I'm not sure why there is such a difference. Perhaps it is due to how much else is going on in the system at the time.

    So, I'm looking for a more precise way to determine which devices or trigger groups cause the event to run. Can this information be determined via the API? Would strEventTriggerGroupData do anything for me? Any other ideas?

    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

    #2
    I don't know of a way to do this with an out-of-the-box solution from HS. It would be a nice feature if HST provided 'the triggering device' of an event.

    Sent from my SCH-R970X using Tapatalk
    HS4Pro on a Raspberry Pi4
    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

    HSTouch Clients: 1 Android

    Comment


      #3
      You can make device script buttons:
      http://homeseer.com/support/homeseer...pt_buttons.htm
      Peter

      http://ohh.pcgsm.nl

      Comment


        #4
        Originally posted by peterpc View Post
        You can make device script buttons:
        http://homeseer.com/support/homeseer...pt_buttons.htm
        Thanks for the replies. I'm not sure how I could use device script buttons to accomplish what I'm looking to do. Could you please explain a bit further?

        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

        Comment


          #5
          Originally posted by mrceolla View Post
          Thanks for the replies. I'm not sure how I could use device script buttons to accomplish what I'm looking to do. Could you please explain a bit further?

          Thank you!
          Here you can find an example:
          http://board.homeseer.com/showthread...tton_AddButton
          Peter

          http://ohh.pcgsm.nl

          Comment


            #6
            Thanks. I was able to find the documentation and examples of what you speak of. Perhaps I'm being dense but I don't see exactly how that would help me accomplish my goal. My idea was to have one event with multiple trigger groups (having ORs in between each condition/trigger), all running one script. I wanted the script to be able to determine which trigger group triggered the event. It seems to me that with this device script button solution that I would need a separate event, triggering a different script button, for each trigger group in my original event. If that is the case I could simply pass different parameters in these separate events. I didn't want a bunch of separate events just so I can determine the trigger. Does that make sense? Am I missing something?

            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


              #7
              The easiest way to do that is to save the current state of each device in your device group somwhere. Either in global variables, or in some ini file. Once the script is called you compare current values against the save values, to see which one really changed.

              There is just no way of catching the "last changed device" in a script as there could be multiple changes in a second?

              Wim
              -- Wim

              Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

              1210 devices/features ---- 392 events ----- 40 scripts

              Comment


                #8
                Perhaps this is what you are looking for:
                RegisterStatusChangeCB
                http://homeseer.com/support/homeseer...ange&criteria=
                It will trigger a script with the following parameters:
                parm(0) = Code part of the Address of the device that changed status
                parm(1) = Full Address of the device that changed status (including Code if present)
                parm(2) = The New value of the device that changed status.
                parm(3) = The Old value of the device that changed status.
                parm(4) = The device reference ID number. Can be used with GetDeviceByRef to find the DeviceClass of the specific device.
                Note that since a function can be called in the callback script, the registration and actual callback can all reside in the same script file.
                Peter

                http://ohh.pcgsm.nl

                Comment


                  #9
                  Thank you again for the replies. Sorry for my delay. Busy time of year.

                  I'm not sure either of those solutions would work for me. I think my biggest problem is that the time between trigger of the event and my script actually running via the same event is seemingly random and up to 12 seconds apart. I am puzzled by the delay.

                  I'm not sure I fully understand w.vuyk's solution and I'm hesitant to try to utilize RegisterStatusChangeCB as that seems overkill for my situation.

                  Is there any way to retrieve the time an event was triggered via a script? If I could capture that I think it would solve my problem.

                  Thank you and Happy Holidays!
                  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


                    #10
                    I think using RegisterStatusChangeCB will be your best bet as I don't believe there's a way to get at the info you want from an event.

                    I use callbacks with a "scene manager" that I wrote years ago (for HS2) and they are pretty easy to implement. The RegisterStatusChangeCB function will register a 'sub' in your script with the HS event engine which will then call that sub whenever any device changes state. The parameters supplied to your script give you all the info you need to determine if the device that changed is one of the devices you are monitoring. This means that you won't use event(s) to monitor your devices and trigger your script because your script is automatically called on every device change.

                    A couple of things to note when registering a callback script:
                    1) Do whatever you have to do in your script as quickly as possible and get out because your script is must be able to respond to many devices changing quickly. If you spend too much time in your script every time its called you may see performance issues and/or missed events in HS.

                    2) In your script create three subs: "EnableCallbacks", "DisableCallbacks" and your application code (the sub that will get called by HS).
                    2.1) In the HS startup script (startup.txt or startup.vb) add a line to call EnableCallbacks in your script.
                    2.2) Create two manually triggered events in HS that call EnableCallbacks and DisableCallbacks respectively. You will find these invaluable while you are debugging.

                    Here's a link to the scripting doc that shows how to enable & use callbacks: RegisterStatusChangeCB
                    Best regards,
                    -Mark-

                    If you're not out on the edge, you're taking up too much room!
                    Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                    Comment

                    Working...
                    X