Announcement

Collapse
No announcement yet.

Trigger "Has Been For At Least" and Device Last Change Time

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

    Trigger "Has Been For At Least" and Device Last Change Time

    Hi.

    I have an event set to fire if some device has been set to "off" for at least 5 minutes. It's a rare condition, but it happened today - switch was set to off, but the event never fired.

    In trying to diagnose why the event never fired I saw that I had set the virtual device to always update the device last change time. I did this so I'd have an easy way to see that the script responsible for checking the conditions for this switch, which are external to HS, was operating.

    This script runs every two minutes, meaning that for a period of time, the Last Change Time for this switch was being set to "Off" every two minutes. Would that have prevented the event condition (Off for at least 5 minutes) from firing?

    Thanks.

    #2
    Originally posted by HSAccord View Post
    Hi.

    I have an event set to fire if some device has been set to "off" for at least 5 minutes. It's a rare condition, but it happened today - switch was set to off, but the event never fired.

    In trying to diagnose why the event never fired I saw that I had set the virtual device to always update the device last change time. I did this so I'd have an easy way to see that the script responsible for checking the conditions for this switch, which are external to HS, was operating.

    This script runs every two minutes, meaning that for a period of time, the Last Change Time for this switch was being set to "Off" every two minutes. Would that have prevented the event condition (Off for at least 5 minutes) from firing?

    Thanks.
    Yes. HomeSeer (and EasyTrigger) look to the last changed date time to calculate when it was last set or changed. You will need to have your script update it without setting the time, or use a separate timer.
    HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

    Comment


      #3
      Thanks rprade.

      I set that virtual device to not update the last change time if the value hasn't changed.

      I'll figure out some other way to make sure the script is running.

      Comment


        #4
        I recently migrated from HS3 to HS4. The event that I use is a safe guard for the garage door. It is a check that ensures that we remembered to close the garage door after we came home. So your first reaction is probably asking why I don’t just use the Exactly 20 minute fuse before it checks that the door is closed. That is a solution for Scenario 1 below but not Scenario 2.

        In HS3, the logic was quite simple:

        If Garage MyQ Garage Door has been open for at least 20 min
        Then Set Device Garage MyQ Garage Door to Close


        But in HS4, the "For At Least" trigger is no longer supported. I am more than willing to rewrite the Event logic but I cannot seem to figure out how to achieve the same flexibility that I had with HS3.

        Here are a couple of scenarios that I hope will offer the rationalization for the event.

        Scenario 1: I park the car in the garage and go inside forgetting to close the garage door. Event automatically closes the door after 20 minutes.

        Scenario 2: I am working outside and want the garage door open while I am busy. I use a garbage to block the laser sensor that runs across the front of the door so the door cannot/will not even try to close. After an hour, I move the garbage can to free up the laser sensor and go back inside but forget the garage door. Scenario 1 says that if door is open more than 20 minutes then it tries to close the door. But that fails because the sensor was blocked. By using the At Least option for the trigger, then it does not matter how many minutes that the door is open beyond the 20 minute threshold, the fact is that the door is open. Condition is always going to be true. I also have an option set that says that the event can only rerun every 15 minutes. When I move the garbage can then the door mechanism will function. On 15 minute intervals, the rerun timer tries to fire. Eventually, it succeeds, the event does its job and the door closes.


        HS3 logic was quite simple. I merely tested for the door to be open more than 20 minutes and if that was true then door was to be closed. I use the Cannot Rerun constraint to retest the door every 15 minutes until the door is successfully closed.

        I hope that this helps. Does anybody have any suggestions?

        Brian

        Comment


          #5
          Originally posted by brmeeke View Post
          But in HS4, the "For At Least" trigger is no longer supported. I am more than willing to rewrite the Event logic but I cannot seem to figure out how to achieve the same flexibility that I had with HS3.
          https://forums.homeseer.com/forum/hs...nger-supported

          TL;DR version is "has been for at least" trigger is functionally the same as a recurring trigger with a "has been for at least" condition. In your given scenario it would look like this:

          IF The event will automatically trigger every 1 min (or whatever interval you are comfortable with)
          AND IF Garage MyQ Garage Door has been Open for at least 20 min
          THEN Set Device Garage MyQ Garage Door to Close

          Comment


            #6
            Originally posted by randy View Post
            Yes. HomeSeer (and EasyTrigger) look to the last changed date time to calculate when it was last set or changed. You will need to have your script update it without setting the time, or use a separate timer.
            Don't want to hijack this thread but would like Randy. if he would, to please clarify:
            If I want to use "value has been for at least" for a device in an Event, I MUST "check mark" the "Do not update .. unless device value changes"? I always assumed HS had it's internal timer for when device value changed.

            Comment


              #7
              Has Been for At Least (or Exactly) look to the Last Changed Date/Time to determine how long a device has been at any particular value. It doesn’t matter if it changed value since HS is only looking at how long it has been at a value. If you update that time without changing the value, HS sees the time at a value as referenced to that time stamp, so the clock starts over, whether or not the value changed at that time. That is exactly why you need to tick "Do not update .. unless device value changes“.
              HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

              Comment


                #8
                Are has-beens resource intensive? Are they examined every second, or only after a value change plus the duration? (Understood from above that value change during the count-up resets the counter.) I don't mind the counter tick because it's intrinsic to the engine, I do sorta mind an evaluation every second rather than scheduled once at a set time after a value change occurs.

                I've generally avoided has-beens but I have a situation that needs them: presence using Wi-Fi in a case where the device goes offline for a couple of tenths of a second as it roams across access points. It's tied to an Alexa speak via Node-Red, so as I walk around she gets chatty as the sub-second status changes queue up and are spoken in sequence. TBH, it's pretty nice that stefxx's new Unifi plugin is that responsive, but this is a new meaning for speed comes at a cost.

                Comment


                  #9
                  Originally posted by sleeve View Post
                  Are has-beens resource intensive? Are they examined every second, or only after a value change plus the duration? (Understood from above that value change during the count-up resets the counter.) I don't mind the counter tick because it's intrinsic to the engine, I do sorta mind an evaluation every second rather than scheduled once at a set time after a value change occurs.
                  HS must be tracking every device at least once a second. (That's how it knows when a device changes.) The event engine appears to do that very efficiently - much more efficiently than the timer function, which looks to me to be a kluge. I avoid timers as much as possible.

                  Likewise, testing for a trigger or condition seems to be done with minimal extra resource utilization over what is required to maintain awareness of all device states. That is what HS does - it's rai·son d'ê·tre.

                  I have seen no evidence that significant resource expenditure occurs if no event is triggered. As far as I can tell, event actions are what consume most resources in HS.
                  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


                    #10
                    Originally posted by Uncle Michael View Post
                    HS must be tracking every device at least once a second. (That's how it knows when a device changes.) The event engine appears to do that very efficiently - much more efficiently than the timer function, which looks to me to be a kluge. I avoid timers as much as possible.

                    Likewise, testing for a trigger or condition seems to be done with minimal extra resource utilization over what is required to maintain awareness of all device states. That is what HS does - it's rai·son d'ê·tre.

                    I have seen no evidence that significant resource expenditure occurs if no event is triggered. As far as I can tell, event actions are what consume most resources in HS.
                    That is almost exactly the way I believe it works. Evaluation of triggers and conditions is continuous and very quick. The only thing that really spends CPU is the actions.

                    HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                    Comment


                      #11
                      Originally posted by sleeve View Post
                      Are has-beens resource intensive?
                      Has been for at least is really a compound trigger and condition. It is basically a once a second recurring trigger coupled with a condition that evaluates the last changed vs the time now. If the combination is true then it runs or is stopped by the next condition. At the trigger time all conditions are evaluated with no additional CPU overhead, unless they are all true.

                      HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                      Comment


                        #12
                        I was always unsure if the check ‘’ do not update unless device ...’ was more of a cosmetic thing vs a real function. And hs was getting device set with something else internally.

                        Is any trigger/condition that use time , is based on the last change time on the device page?
                        If yes , With the ‘’do not update device’’... checked on a device x, means that if the device won’t trigger any time based ‘’ has been set ..etc’’ event? And if I manually change that time (let’s say 1h less) from a one liner script, I can set a trigger to fire an event one hours less too?

                        please say if this is not clear, I’m french and need to sleep .

                        Thanks.

                        Comment


                          #13
                          Originally posted by MattL0 View Post
                          I was always unsure if the check ‘’ do not update unless device ...’ was more of a cosmetic thing vs a real function. And hs was getting device set with something else internally.
                          I do not believe there is any other "timer" running behind the scenes. The last change time is what HS uses to determine how long a device has been in its current state.

                          Is any trigger/condition that use time , is based on the last change time on the device page?
                          If yes , With the ‘’do not update device’’... checked on a device x, means that if the device won’t trigger any time based ‘’ has been set ..etc’’ event? And if I manually change that time (let’s say 1h less) from a one liner script, I can set a trigger to fire an event one hours less too?

                          please say if this is not clear, I’m french and need to sleep .
                          As you suspected, that question is not clear.

                          Normally, one is interested in when a device actually changes value or state, but there are situations where 'resetting' a device to a state that it is already in is (logically) equivalent to changing its state. In those cases, you can uncheck that option. I believe, though, that HS logic then changes for that device, and it will consider a 'set to' to be equivalent to a 'change to' and the 'last change' time becomes the 'last set' time. Consequently, conditions like 'has been for at least' will test the time since the device state was set even if an actual change in state did not occur.
                          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


                            #14
                            Thanks Mike.

                            Comment


                              #15
                              Brian,

                              HS3 logic was quite simple. I merely tested for the door to be open more than 20 minutes and if that was true then door was to be closed. I use the Cannot Rerun constraint to retest the door every 15 minutes until the door is successfully closed.

                              I hope that this helps. Does anybody have any suggestions?

                              was thinking about this and may have a suggestion.

                              If garage door is open for exactly 20 minutes
                              or
                              if garage door is open for exactly 36 minutes

                              then setdevicelastchange devref#, dateadd("n",-21,now)

                              then close garage door(only attempt one time)




                              So when the door opens the devicelastchange starts. When it gets to 20 minutes it tries to shut it then it sets the devicelastchange to now have been on for 21 minutes so
                              your 20 minutes time does not get triggered again. Now 21 to 36 is your 15 minute cycle and if it fails to shut at 36 it resets the time to 21 and continues that cycle until it closes.

                              And when it closes the time gets reset back to reality.
                              Stuart


                              Comment

                              Working...
                              X