Announcement

Collapse
No announcement yet.

Help with use of Trigger "Device Has Been/For Exactly"

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

    Help with use of Trigger "Device Has Been/For Exactly"

    I have two motion sensors in my office. I would like to have the lights turn off if there is no motion detected by both sensors for 5 minutes. So, I thought I would create an event trigger that would be like this:

    IF Motion Sensor 1 has been "no event" for exactly 5 minutes
    AND Motion Sensor 2 has been "no event" for exactly 5 minutes
    THEN Turn off the lights

    However, when I try to create this, I am only allowed to select "Has Been/For Exactly" once in the trigger. When I add the second condition, there is no "Has Been/For Exactly" option. If I use "OR IF", I can get the option again, but I don't want an OR condition, I am looking for an "AND" condition.

    Question 1: I understand that the "Has Been/For At Least" option was deprecated and replaced with "Has Been/For Exactly". I also read that "For Exactly" does the same thing. Is that correct? In my case, it would seem more logical to make the condition be >=5 minutes (like the "At Least" option would do). That way, if Homeseer was busy and didn't trigger the event when the time was exactly 5 minutes, it would be still work. Is this something to worry about or will Homeseer still trigger the event if there's been no event for 5 minutes and 1 second?

    Question 2: Does anyone know why this option can only be selected once?

    Question 3: What other suggestions do you have to accomplish this simple task?

    Note: I have gone down the route of starting a timer for each sensor when "no event" is detected and having third event turn the lights off when both timers exceed 5 minutes. This of course requires having the timers reset when motion is detected. This mostly works, but feels inelegant.


    Date/time=11/12/2022 9:52:36 PM CST
    Version=HomeSeer HS4 ZEE S2 (Upg from HS3ZS2) Edition 4.2.16.0 (Linux)
    MONO Version=Mono JIT compiler version 6.10.0.104 (tarball Fri Jun 26 19:59:14 UTC 2020)

    License=Registered
    Confguration File=/usr/local/HomeSeer/Data/HomeSeerData.json
    Uptime=12 Days 14 Hours 28 Minutes 19 Seconds
    Lan IP=192.168.1.146 (HTPiHubG1)
    Device Count=300
    Event Count=119
    Plugins Enabled=Z-Wave:,LIFX:,SDJ-Health:,HS MyQ:,Tuya:
    Modules/Threads=86 Modules, 50 Threads
    Available Threads=399
    HomeSeer Memory Used=166 Mbytes
    Plugins Installed=Govee Plugin 4.0.0.0,HS MyQ 4.0.8.0,LIFX 4.0.7.0,SDJ-Health 3.1.0.4,Tuya 4.0.37.0,Z-Wave 3.0.2.4,Z-Wave GUI 0.3.0.0
    Disk Size=29.72GB​

    #2
    Originally posted by ChrisMiller View Post
    I have two motion sensors in my office. I would like to have the lights turn off if there is no motion detected by both sensors for 5 minutes. So, I thought I would create an event trigger that would be like this:

    IF Motion Sensor 1 has been "no event" for exactly 5 minutes
    AND Motion Sensor 2 has been "no event" for exactly 5 minutes
    THEN Turn off the lights
    It is virtually impossible for two devices to have been set at “Exactly” 5 minutes ago. Time stamps are down to the millisecond. That is why Conditions are never based upon an exact instant. IF is a Trigger, AND IF is a condition. The condition has to be based on a device’s state, not of it having changed at the instant a Trigger is true, or having changed at an exact instant in the past


    However, when I try to create this, I am only allowed to select "Has Been/For Exactly" once in the trigger. When I add the second condition, there is no "Has Been/For Exactly" option. If I use "OR IF", I can get the option again, but I don't want an OR condition, I am looking for an "AND" condition.
    As I wrote above, Triggers and Conditions are totally different animals. It is not a Trigger and a “second” Condition, it is a Trigger and First Condition


    Question 1: I understand that the "Has Been/For At Least" option was deprecated and replaced with "Has Been/For Exactly". I also read that "For Exactly" does the same thing. Is that correct? In my case, it would seem more logical to make the condition be >=5 minutes (like the "At Least" option would do). That way, if Homeseer was busy and didn't trigger the event when the time was exactly 5 minutes, it would be still work. Is this something to worry about or will Homeseer still trigger the event if there's been no event for 5 minutes and 1 second?
    The “at least” option is only deprecated for Triggers, it remains in Conditions. A solution for what you’re trying to do is:

    IF Motion Sensor 1 has been "no event" for exactly 5 minutes
    AND Motion Sensor 2 has been "no event" for at least 5 minutes

    OR IF Motion Sensor 2 has been "no event" for exactly 5 minutes
    AND Motion Sensor 1 has been "no event" for at least 5 minutes

    THEN Turn off the lights​

    This will Trigger if either device has been ‘no event” for Exactly 5 minutes and the other has been “no event” for 5 minutes or more. This covers regardless of which goes to “no event” last.


    Question 2: Does anyone know why this option can only be selected once?

    Question 3: What other suggestions do you have to accomplish this simple task?

    Note: I have gone down the route of starting a timer for each sensor when "no event" is detected and having third event turn the lights off when both timers exceed 5 minutes. This of course requires having the timers reset when motion is detected. This mostly works, but feels inelegant.
    An Event that is much more forgiving of time differences or missed Triggers could be:

    IF this event will automatically trigger every 1 s
    AND IF Motion Sensor 1 has been "no event" for at least 5 minutes
    AND Motion Sensor 2 has been "no event" for at least 5 minutes
    AND IF the lights are not equal to Off

    THEN Turn off the lights​

    Even though it triggers every second, it will only run once when all three Conditions are true. Once it runs, the lights are Off and it will not run again until the lights are On.

    The retired Trigger of “This Device has been/for at least” was actually a compound Trigger and can be duplicated by:

    IF this event will automatically trigger every 1 s
    AND IF This Device has been/for at least….

    You can see how this can get you in trouble. Once the Condition is True the event will run once every second until the Condition is False. This can be prevented by using a Device controlled by the Event as a Condition, like the light in my example above.
    HS4 Pro, 4.2.18.9 Windows 10 pro, Supermicro LP Xeon

    Comment


      #3
      randy Thank you for the explanation and suggestions. That was helpful. I like the 2nd suggestion better for the reasons you mentioned (but will try the first one first for a while to see how well it works).

      Also, I've read posts that discourage use of timers. Why is that? I did get this working mostly by doing the following:
      [Lights On Event]
      IF Motion Sensor 1 detects motion
      AND Timer = 0
      OR IF Motion Sensor 2 detects motion
      AND Timer = 0
      THEN Turn on the lights and start the timer

      [Timer Rest Event]
      IF Motion Sensor 1 detects motion
      AND Timer > 0
      OR IF Motion Sensor 2 detects motion
      AND Timer > 0
      THEN Rest the Timer to 1 second

      [Lights Off Event]
      IF Timer >= 5 minutes
      THEN Turn off the lights and stop the timer and set the timer to 0

      This logic seems bulletproof to me, but there are times where the motion sensors don't report detecting motion (when there has clearly been motion). But that's a different problem.

      One last question: Do you know how the Homeseer event triggering "loop" works in general? I would guess that all of the trigger conditions are put into an array and some thread continuously loops through them testing to see if any are true. When you create a trigger that fires every second, does that eat up a lot of resources (I'm running on an older RPi) and wondered how many things it can handle. Given Homeseer is the only app, I would think even an older RPi would easily be able to keep up with a 50ish events.

      Comment


        #4
        Originally posted by ChrisMiller View Post
        randy Thank you for the explanation and suggestions. That was helpful. I like the 2nd suggestion better for the reasons you mentioned (but will try the first one first for a while to see how well it works).

        Also, I've read posts that discourage use of timers. Why is that? I did get this working mostly by doing the following:
        [Lights On Event]
        IF Motion Sensor 1 detects motion
        AND Timer = 0
        OR IF Motion Sensor 2 detects motion
        AND Timer = 0
        THEN Turn on the lights and start the timer

        [Timer Rest Event]
        IF Motion Sensor 1 detects motion
        AND Timer > 0
        OR IF Motion Sensor 2 detects motion
        AND Timer > 0
        THEN Rest the Timer to 1 second

        [Lights Off Event]
        IF Timer >= 5 minutes
        THEN Turn off the lights and stop the timer and set the timer to 0

        This logic seems bulletproof to me, but there are times where the motion sensors don't report detecting motion (when there has clearly been motion). But that's a different problem.
        If a timer works for you, use one. You will read all sorts of things on these forums. I find that in most cases a timer can make an Event structure more complex, when looking at a Device’s last change time stamp would work. It’s your choice, if an Event works for you it is fine. You will read users fretting about a structure requiring too many Events or an Event using multiple Trigger/Condition blocks is not “elegant”. HomeSeer is powerful and reliable and if you learn to speak its language it can do almost anything. My system has thousands of Devices and Events. It just works. I don’t worry about “pretty” or “elegant” because I rarely look at Events after creating them, they just do what they are supposed to.

        One last question: Do you know how the Homeseer event triggering "loop" works in general? I would guess that all of the trigger conditions are put into an array and some thread continuously loops through them testing to see if any are true. When you create a trigger that fires every second, does that eat up a lot of resources (I'm running on an older RPi) and wondered how many things it can handle. Given Homeseer is the only app, I would think even an older RPi would easily be able to keep up with a 50ish events.
        An Event only consumes resources when it actually runs. Triggers are Evaluated every second, but unless the Conditions test true, the resources consumed are negligible. My 1600 Event system ran as a test on a Pi 4 and was fine. On my Windows server (a low power Xeon) runs at less than 10% CPU. Your system should run fine on anything. If you were to grow to more than 4-500 Events you might look for a little more processor, because it will become slow at editing or creating Events, but it will still execute them properly. Read through the Event Clinic forum using the Table of Contents. Even though the screenshots are HS3, the function is the same in HS4.

        HS4 Pro, 4.2.18.9 Windows 10 pro, Supermicro LP Xeon

        Comment

        Working...
        X