Announcement

Collapse
No announcement yet.

Need help trying to trigger a virtual switch

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

    Need help trying to trigger a virtual switch

    I am working on a virtual switch to track if all windows are closed and ready for the AC as well as a notification for when it is heating up or cooling off outside. Essentially the virtual switch will help tell if windows are already open when it gets cool outside or if we need to close them etc.

    I am trying to figure out how to trigger the virtual switch if all of the sensors are reading closed. I can get it to work if I close a specific sensor last but that doesn't always work and even harder to get the wife to always follow that logic. I got to imagine there is a way to change the device when all sensors become closed but I am missing it.

    Here is what I have so far and if I need to tweak it or take it from another angle I can, just trying to get wrapped around this. Thanks


    #2
    Create a counter that increases each time a window closes and decreases each time one opens. Trigger your event when the counter reaches the number of windows.

    Comment


      #3
      Originally posted by mikaluch View Post
      Create a counter that increases each time a window closes and decreases each time one opens. Trigger your event when the counter reaches the number of windows.
      Brilliant! I will give that a try. I would think you could do the reverse as well and trigger off the counter being 0 but I will give the add 1 method a go! I have been using counters for other projects but didn't think of it for this one.

      Quick follow-up, you would have to build with a bunch of or statements yes? To increment the counter that is. One event but with if device value changes to closed OR if device value changes to closed OR if... right? Just trying not to create 30+ events.

      Thanks again for the idea.

      Comment


        #4
        That sounds right but I don't have any window sensors yet so I've never tried that method. We have perfect weather every day in SoCal. No need for air conditioning or closing the windows.

        Comment


          #5
          If only we were so lucky here, hit high 90s today then cooled off in the evening... Hence closing and opening windows frequently. Need ac in the middle of the day mostly until we start clearing the 100s for consecutive days

          Comment


            #6
            Originally posted by norcalhkr View Post
            I am working on a virtual switch to track if all windows are closed and ready for the AC as well as a notification for when it is heating up or cooling off outside. Essentially the virtual switch will help tell if windows are already open when it gets cool outside or if we need to close them etc.

            I am trying to figure out how to trigger the virtual switch if all of the sensors are reading closed. I can get it to work if I close a specific sensor last but that doesn't always work and even harder to get the wife to always follow that logic. I got to imagine there is a way to change the device when all sensors become closed but I am missing it.

            Here is what I have so far and if I need to tweak it or take it from another angle I can, just trying to get wrapped around this. Thanks

            You don't need counters or a large number of events. Just create an event with a recurring trigger, have the virtual device as the first condition then have all of the windows and doors as conditions. The action will turn the virtual device on, which will prevent the event from running again. Select "Cannot Re-Run For:" at a value less than the recurring rate to keep the event from running again in the few milliseconds it takes to change the status of the virtual device - this step is not required, but is a good programming practice. HomeSeer has a propensity to sometimes hammer recurring events at startup. This event will only run when the last window or door is closed.

            The advantage over a counter is simplicity and it can never get out of sync. If a door or window changes state while HomeSeer is not running, is immediately reevaluated when it is running - a counter would be permanently out of sync.

            You can have it recur as frequently as you think is necessary, it could trigger once every 5 seconds with "Cannot Re-Run For:" set to 1 second if you want fast response. There is no overhead for the event being triggered unless all of the conditions are met. I didn't feel like fast response was important, so I arbitrarily chose 1 minute. You could create events that would be instant, but it would require a huge stack of IF/AND IF plus OR IF/AND IF trigger/condition groups, or a simple script would do it. The recurring trigger is by far the easiest.

            EDIT: I removed the second event to turn the virtual device off because it was incorrect. See post 11 below for the corrected event.
            .
            Attached Files
            Last edited by randy; May 28, 2016, 12:00 PM.

            Comment


              #7
              Randy - Wouldn't the second event only trigger if all the windows were open? I would think using OR IF so it triggered the A/C off if any window was open.
              Last edited by prnorton; May 28, 2016, 09:58 AM.

              Comment


                #8
                Just another way, but here's how I did it to turn heat back on. One event to see if any window closed, then that runs another event to see if every window is closed, then turn the heat on. It turns the heat on as soon as the last window is closed.

                Click image for larger version

Name:	WindowEvents.png
Views:	1
Size:	105.6 KB
ID:	1184871

                Comment


                  #9
                  Originally posted by prnorton View Post
                  Randy - Wouldn't the second event only trigger if all the windows were open? I would think using OR IF so it triggered the A/C off if any window was open.
                  You're correct. That's what I get for posting while playing with a 10 week old puppy early in the morning. I'll fix the post for future viewers so I don't send them down the wrong path.

                  Comment


                    #10
                    Originally posted by jhearty View Post
                    Just another way, but here's how I did it to turn heat back on. One event to see if any window closed, then that runs another event to see if every window is closed, then turn the heat on. It turns the heat on as soon as the last window is closed.

                    [ATTACH]54504[/ATTACH]
                    That is a good solution and would work for enabling but not disabling the virtual device. It would also give instant response to the change in state of any door or window.
                    Last edited by randy; May 28, 2016, 12:02 PM.

                    Comment


                      #11
                      Since I screwed up and posted the incorrect logic in the compliment event to turn the virtual device off, I created an event with the correct logic. This event will trigger when any of the doors or windows are opened and turn the virtual device off.
                      .
                      Attached Files

                      Comment


                        #12
                        Originally posted by rprade View Post
                        That is a good solution and would work for enabling but not disabling the virtual device. It would also give instant response to the change in state of any door or window.
                        Correct. I also have two other events to handle the other direction.

                        Click image for larger version

Name:	WindowEvents.png
Views:	1
Size:	120.6 KB
ID:	1184876

                        Comment


                          #13
                          Originally posted by jhearty View Post
                          Correct. I also have two other events to handle the other direction.

                          [ATTACH]54509[/ATTACH]
                          Why is the second event manually triggered? Just trying to learn more as I keep adding more to the system.

                          Like seeing all of these different ways to configure. Great stuff really

                          Comment


                            #14
                            Originally posted by norcalhkr View Post
                            Why is the second event manually triggered? Just trying to learn more as I keep adding more to the system.

                            Like seeing all of these different ways to configure. Great stuff really
                            He's calling the second event from the first and having the conditions honored. It is an easy way to have multiple triggers all sharing a large group of common conditions. Any of the IF or OR IF triggers in the first event will call the second event. The second event requires that all windows be closed in order to be true. As a result, every time he closes a window, it evaluates if all of the other windows are closed. That way he gets instant response to the virtual device when the last window/door is closed. The event I posted will do the same thing, it just evaluates the status of all windows once per minute. His has the advantage of being instant, mine has the advantage of being a single event. In terms of HomeSeer resources, they are both about equal - one is not "better" than the other.

                            Comment


                              #15
                              Originally posted by rprade View Post
                              He's calling the second event from the first and having the conditions honored. It is an easy way to have multiple triggers all sharing a large group of common conditions. Any of the IF or OR IF triggers in the first event will call the second event. The second event requires that all windows be closed in order to be true. As a result, every time he closes a window, it evaluates if all of the other windows are closed. That way he gets instant response to the virtual device when the last window/door is closed. The event I posted will do the same thing, it just evaluates the status of all windows once per minute. His has the advantage of being instant, mine has the advantage of being a single event. In terms of HomeSeer resources, they are both about equal - one is not "better" than the other.
                              Thanks for the detailed explanation, that helps clear up what you guys are achieving and I like it. Thinking I might still use the counter as well to tell how many windows are open while using your examples to tell the true state of the window. My thought is to have a speak event when the HVAC wants to run and windows are open to say how many are open. The next step would be to speak which are open but I think that is a bit beyond my time right now.

                              Comment

                              Working...
                              X