Announcement

Collapse
No announcement yet.

Trigger and trigger conditions

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

    Trigger and trigger conditions

    Hi all,

    This is probably really simple, but so much so it's got me puzzling at the mo...

    I have a Homeseer device which is a device variable...

    This variable can be set to values of either 0, 1 or 2 depending on certain conditions...

    I have no problem using it as a trigger when it changes to a specified value...

    But, there is a circumstance when I need to know what it was *before* it changed... for instance, when the value becomes 0, I need to know which of the following is true:

    value changed from 1 to 0
    value changed from 2 to 0

    Each of the two possible conditions requires different actions.

    Initially I tried using the "becomes not equal to" condition, but this doesn't work right since it triggers on too many conditions - e.g. if I use "value becomes not equal to 2" it triggers when:

    value changed from 2 to 0 (correct, - as I want)
    value changed from 1 to 0 (not what I want!)
    value changed from 0 to 1 (also not what I want!)

    Logically speaking the 2nd two conditions are "correct" triggers I guess, but aren't what I want. I want to only trigger on the first condition, i.e. when the value stops being equal to 2.... and at the moment, I can't seem to find a combination of triggers and conditions that will do this...

    I'm now wondering if I will have to use a global variable to track the device variable value and check against that to see what it changed FROM....

    Can anyone enlighten me?

    TIA

    Paul G.

    #2
    Paul you could always store the last value in a virtual device.
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      I've done it for the time being with a global variable, and it seems to be working as I want for now...

      Each time the value changes to either 1 or 2 I set the global variable to that value. Each time it changes to 0 I check that global variable first to see what it was before, then change it to 0. Thus I only need 3 events, and no faffing around with complex conditions on the event properties...

      If anyone is interested, this is actually for tracking my Comfort alarm panel arm states;
      0=disarmed
      1=full arm
      2=part arm (night mode)
      The system is part armed (state 2) every night when we go to bed, and has to be disarmed every morning once it sees someone coming downstairs. Thus the transition from 2 to 0 happens every morning and doesn't require much special response. Obviously it's full armed whenever we leave the house, and in this instance Homeseer sets a number of other security programs into effect. Therefore when we disarm from this state Homeseer has to un-set those additional security programs, which in turn invokes various other scripts and notifications... hence the requirement to know which mode it has been disarmed from, since I don't want all those extra scripts running every morning!

      Anyway, long story short, I seem to have it going OK using the global variable method, so problem solved...

      Paul G.

      Comment


        #4
        Paul,

        I have used something similar with my HAI system for so long now that I am seriously thinking of adding it to the HAI plug-in. There are too many times when the security system status becomes disarmed that I also need to know was it disarmed after being Away or disarmed after being in Night mode? It makes a big difference!

        I created an event that uses the "any value" trigger on the plug-in device that tracks the security system status. All the event does (script really) is to take the current status and move it to a virtual device "A", and to take the status from "A" and move it to "B". Thus, "A" always has the previous state for the instant before it is changed, and when passed along to "B" the result is that "B" always contains the previous state after any change. Thus, if the current state is "Disarmed", then the state of device "B" will be "Armed Night" or "Armed Away".

        Here is the script code if it helps:


        Sub Main()

           &nbspsCStat = hs.GetDeviceCode("HAI System Security Status")
           &nbspsPStat = hs.GetDeviceCode("HAI System Previous Status")
           &nbspsHStat = hs.GetDeviceCode("HAI System Previous Status Hold")

           &nbsplPrev = hs.DeviceValue(sPStat)
           &nbspstrPrev = hs.DeviceString(sPStat)

           &nbsplNew = hs.DeviceValue(sCStat)
           &nbspstrNew = hs.DeviceString(sCStat)

           &nbsplHold = hs.DeviceValue(sHStat)
           &nbspstrHold = hs.DeviceString(sHStat)

           &nbsphs.WriteLog "HAI","Previous was " & strPrev & " and new is " & strNew


           &nbsphs.SetDeviceString sPStat, strHold
           &nbsphs.SetDeviceValue sPStat, lHold

           &nbsphs.SetDeviceString sHStat, strNew
           &nbsphs.SetDeviceValue sHStat, lNew


        End Sub
        Regards,

        Rick Tinker (a.k.a. "Tink")

        Comment

        Working...
        X