Announcement

Collapse
No announcement yet.

How to create a countdown timer

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

    How to create a countdown timer

    I have a HomeSeer HS-FC200+ Fan Controller Switch that I use in the master bedroom for the ceiling fan. I've set up a countdown timer to automatically turn the fan off after a predefined time period. I'm using HS Version: 4.1.10.0 and this is how I've set it up. I've used 20 minutes for this example.

    Create a timer called...

    Fan Timer - Countdown

    Next, create an Event called...

    Fan Timer - 20 Minutes

    IF

    Trigger = A Device's Value is...
    Trigger Type = This Device Changes and Becomes...
    Device = MBR Ceiling Fan
    Feature = Switch - MBR Ceiling Fan

    Changes and becomes:
    Trigger Value = ON

    THEN


    Action = Control a Device
    Device = MBR Ceiling Fan
    Set Control = ON


    +

    Action = Control a Timer
    Timer = Fan Timer - Countdown
    Timer Action = Set to Time

    Days = 0 Hours = 0 Minutes = -20 Seconds = 0
    Note: Value should be a negative number

    +

    Action = Control a Timer
    Timer = Fan Timer - Countdown
    Timer Action = Resume


    Note: When you save this Event, the Set Timer Action will not show -20 minutes! It will probably show something on the order of "Set Timer Fan Timer - Countdown to time 0 Seconds" <<< Note: the Zero (0) Seconds! HomeSeer does not show a negative value for time.

    Now we need an event to turn the fan off...

    Create an Event called...

    Fan Timer - Expired

    IF

    Trigger = A Device's Value is...
    Trigger Type = This Device Changes and Becomes...
    Device = MBR Ceiling Fan
    Feature = Switch - MBR Fan

    Changes and becomes:
    Trigger Value = Off

    +

    OR IF

    Trigger = A Timer's Value is...
    Trigger Type = A Timer's Value Becomes...
    Timer = Fan Timer - Countdown

    Days = 0 Hours = 0 Minutes = 0 Seconds = -1
    Note: You must use the negative one value as HomeSeer will not allow you to check for a zero value here.

    THEN

    Action = Control aTimer
    Timer = Fan Timer - Countdown
    Timer Action = Stop

    +

    Action = Control a Timer
    Timer = Fan Timer - Countdown
    Timer Action = Set to Time

    Days = 0 Hours = 0 Minutes = 0 Seconds = 0

    +

    Action = Control a Device
    Device = MBR Ceiling Fan
    Set Control = Off




    This is a simplified version of what I'm doing with the HS-FC200+. In addition to controlling my fan with four speeds, I'm also using the scenes to set different run times and the key held down value to disable the timer function and run the fan 24/7. I also set the status lights to indicate the approximate time remaining.

    From what I've read on the forums so far, HomeSeer doesn't actually have a countdown timer but I've been able to implement one by starting at a negative value for the time. Technically, it's not a count down timer. It still counts up but since it starts at a negative value it counts up to zero instead of counting down to zero. Also of interest is the fact that if you look at the running timer it does not show the negative sign so it actually looks like it's counting down. With minor changes, this same setup will work for delayed off timing for motion detector lighting as each time the motion detector triggers it would reset the timer back to 20 minutes and won't turn the lights off until there is no motion detected for the entire time period.

    Hope this helps,

    Roger

    #2
    Originally posted by Roger D View Post
    I have a HomeSeer HS-FC200+ Fan Controller Switch that I use in the master bedroom for the ceiling fan. I've set up a countdown timer to automatically turn the fan off after a predefined time period. I'm using HS Version: 4.1.10.0 and this is how I've set it up. I've used 20 minutes for this example.

    Create a timer called...

    Fan Timer - Countdown

    Next, create an Event called...

    Fan Timer - 20 Minutes

    IF

    Trigger = A Device's Value is...
    Trigger Type = This Device Changes and Becomes...
    Device = MBR Ceiling Fan
    Feature = Switch - MBR Ceiling Fan

    Changes and becomes:
    Trigger Value = ON

    THEN


    Action = Control a Device
    Device = MBR Ceiling Fan
    Set Control = ON


    +

    Action = Control a Timer
    Timer = Fan Timer - Countdown
    Timer Action = Set to Time

    Days = 0 Hours = 0 Minutes = -20 Seconds = 0
    Note: Value should be a negative number

    +

    Action = Control a Timer
    Timer = Fan Timer - Countdown
    Timer Action = Resume


    Note: When you save this Event, the Set Timer Action will not show -20 minutes! It will probably show something on the order of "Set Timer Fan Timer - Countdown to time 0 Seconds" <<< Note: the Zero (0) Seconds! HomeSeer does not show a negative value for time.

    Now we need an event to turn the fan off...

    Create an Event called...

    Fan Timer - Expired

    IF

    Trigger = A Device's Value is...
    Trigger Type = This Device Changes and Becomes...
    Device = MBR Ceiling Fan
    Feature = Switch - MBR Fan

    Changes and becomes:
    Trigger Value = Off

    +

    OR IF

    Trigger = A Timer's Value is...
    Trigger Type = A Timer's Value Becomes...
    Timer = Fan Timer - Countdown

    Days = 0 Hours = 0 Minutes = 0 Seconds = -1
    Note: You must use the negative one value as HomeSeer will not allow you to check for a zero value here.

    THEN

    Action = Control aTimer
    Timer = Fan Timer - Countdown
    Timer Action = Stop

    +

    Action = Control a Timer
    Timer = Fan Timer - Countdown
    Timer Action = Set to Time

    Days = 0 Hours = 0 Minutes = 0 Seconds = 0

    +

    Action = Control a Device
    Device = MBR Ceiling Fan
    Set Control = Off




    This is a simplified version of what I'm doing with the HS-FC200+. In addition to controlling my fan with four speeds, I'm also using the scenes to set different run times and the key held down value to disable the timer function and run the fan 24/7. I also set the status lights to indicate the approximate time remaining.

    From what I've read on the forums so far, HomeSeer doesn't actually have a countdown timer but I've been able to implement one by starting at a negative value for the time. Technically, it's not a count down timer. It still counts up but since it starts at a negative value it counts up to zero instead of counting down to zero. Also of interest is the fact that if you look at the running timer it does not show the negative sign so it actually looks like it's counting down. With minor changes, this same setup will work for delayed off timing for motion detector lighting as each time the motion detector triggers it would reset the timer back to 20 minutes and won't turn the lights off until there is no motion detected for the entire time period.

    Hope this helps,

    Roger
    Wow, sure glad I didn't get HS4! In HS3, all we had to do was define a delayed "off" event....

    IF First Floor Arizona Room Air Purifier changes and becomes On
    Then
    Set Device First Floor Arizona Room Air Purifier to Off
    after a delay of 15 Minutes, 0 Seconds

    Must be some bodacious "code bloat" going on in 4.


    Jim Speiser
    38-year veteran of Home Automation
    Still don't know squat

    Comment


      #3
      Roger D you're making it way over complicated. Timer's are not really needed in HS if you think about your automation routines in terms of state machine design.

      JimSpy that's exactly how we do it in HS4 also

      Comment


        #4
        Originally posted by TC1 View Post
        Roger D you're making it way over complicated. Timer's are not really needed in HS if you think about your automation routines in terms of state machine design.

        JimSpy that's exactly how we do it in HS4 also
        I kinda guessed that it was. I don't even know what "state machine design" is, other than a Chicago political structure, but I shore 'nuff appreciate the delayed event actions thingy.

        RogerD, I do hope you read this before attempting to write your own script interpreter. SPOILER: There's one of those built in, as well!

        (I hope you don't mind the friendly ribbing. You definitely get "A"s for effort & creativity!)


        Jim Speiser
        38-year veteran of Home Automation
        Still don't know squat

        Comment


          #5
          And i should clarify that I use Wait statements. It's super simple...

          If trigger is true
          Wait X minutes
          Set device to Off.

          Done

          Roger D , I've ranted in these forums that using Timers in HS requires too much management overhead (as you've already discovered), there's not many use cases where they are actually needed. My advice is to stay away from them, there are many ways to create timed automation routines without them (and no coding or scripting required).

          Comment


            #6
            Greetings TC1 and @JimSpy

            Since I simplified some of the above and possibly left out some explainations, I think you may have missed some important items. What I was going for in the above in controlling my fan, I wanted to...

            Have a default time set if I pressed the top paddle once. This is what the Fan Timer - 20 Minutes Event does.
            Have the ability to reset the running timer to a different value just by double, triple, etc., tapping the top paddle.
            Have the ability to turn the fan on and run constantly.
            Have the ability to view the remaining time available on the web gui.
            Have a visual way to determine the remaining time on the timer by setting the color and/or number of LEDs lit on the switch.
            Do this with no scripting involved.
            Most importantly, I just wanted to be able to create a countdown timer.

            On a side note, I don't understand how either counter proposed method would work. Using a "wait time" or "after a delay time" does not give me the neccessary output. I'm very new to HomeSeer so please (kindly) point me in the right direction if I'm wrong. If I wanted to have a load turn off after after a pre-defined time of X minutes then the following works...

            If trigger is true
            Wait X minutes
            Set device to Off.

            From what I can tell however, is that there can be a few issues in doing it this way...
            There is no way to indicate when the load will turn off.
            The timer can not be reset by re-triggering the input.
            The currently running delay time can not be altered by a different trigger input.


            Most importantly, say for example I have a wait period of 10 minutes programmed.

            I walk into a room and turn the light on. The 10 minute wait time starts.
            Six minutes later I walk out of the room and turn the light off. The original 10 minute timer is still running.
            A minute later my wife walks in and turns the light on. An additional 10 minute timer now starts.
            Three minutes later the first timer expires and the light turns off leaving the wife in the dark. WAF = -20
            One minute later, the now frustrated wife fumbles through the dark to turn the lights back on. A third 10 minute timer starts.
            Five minutes later timer #2 turns the lights off again! WAF = -50
            Thirty seconds later (she knows the way now), the now infuriated wife fumbles through the dark to turn the lights on again. A forth 10 minute timer starts.
            ... it happens a third time and the wife rips the switch out of the wall and yells at me cause she thinks that I'm the one messing with her.


            Jim, friendly ribbing is welcome. Thanks!

            Comment


              #7
              Hi Roger,

              Thank you for the better explanation, I now understand exactly what you want to do. I do something similar with my bathroom exhaust fan, again, all without using an HS timer.

              Since you mentioned paddle taps, let's go on that premise. Just for the sake of brevity, let's assume two triggers (you can extrapolate this out to as many as needed), paddle up once and twice.

              You'll need a matching event for each trigger.

              Event#1
              Trigger = If paddle up once
              Then
              Set light On
              Set first switch status light to On
              Cancel another running event = Event#2
              Wait 10 minutes
              Set light Off
              Set first switch status light to Off
              (check off the advanced option "Event Cannot Re-Run for: 10 minutes)


              Event#2
              Trigger = If paddle up twice
              Then
              Set light On
              Set second switch status light to On
              Cancel another running event = Event#1
              Wait 20 minutes
              Set light Off
              Set second switch status light to Off
              (check off the advanced option "Event Cannot Re-Run for: 20 minutes)

              EventOff
              Trigger = If paddle down once
              Then
              Set light Off
              Cancel another running event = Event#1
              Cancel another running event = Event#2
              Set switch status lights 1 and 2 to off

              I wrote the above in pseudo event statements, hopefully you get the idea. I haven't totally debugged this, but in general it should work. If you come across a use case where this fails you then let us know and I' m sure I can tweak it to work the way you want. Obviously rename events to what makes sense to you.

              If you are using one of the HS WD200 dimmers (which I suspect) then you can get creative with the status lights (make them blink) while the delay off time is counting down.

              Comment


                #8
                A couple of disjointed thoughts:

                -Complicated light control to save energy with LEDs is pretty meaningless. Automated light control should be for convenience.
                - Remember that events can cancel other events that have a wait statement. A 20 minute fan "timer" requires three commands 1) Turn on fan 2) Wait 20 minutes 3) Turn off fan. If you want to cancel that timer, another event just uses the "Cancel another running even" command. You don't need to know that the other programming is actually running. The the cancel command can be used just in case another program is running.
                - You thinking of design as a few running program. That's not how programming with triggers should usually be done.



                Comment


                  #9
                  Roger,

                  I think to accomplish your listed objectives, the timer is a reasonable way to do it. This said, there's an action you may not be aware of that could be useful in some instances--in particular, the WAF killer example you described. Delayed actions can be cleared as part of the "turn on" event, thereby resetting the off delay each time the switch is turned on. E.g.,

                  Click image for larger version  Name:	Capture.PNG Views:	0 Size:	17.1 KB ID:	1444529
                  -Wade

                  Comment


                    #10
                    Originally posted by cc4005 View Post
                    Roger,

                    I think to accomplish your listed objectives, the timer is a reasonable way to do it. This said, there's an action you may not be aware of that could be useful in some instances--in particular, the WAF killer example you described. Delayed actions can be cleared as part of the "turn on" event, thereby resetting the off delay each time the switch is turned on. E.g.,

                    Click image for larger version Name:	Capture.PNG Views:	0 Size:	17.1 KB ID:	1444529
                    Even -I- wasn't aware of that. (On my drop down it says "Cancel Delayed..." instead of Remove, but I assume it's the same).

                    Not that it's been a problem for me. My WAF is at -32000 currently anyway, so I stopped worrying about it. I just have to keep my screwdrivers hidden where she can't find them.


                    Jim Speiser
                    38-year veteran of Home Automation
                    Still don't know squat

                    Comment


                      #11
                      Greetings TC1, cc4005, et al.,

                      If I control my device as suggested how can I get the value of the delay time remaining? I use the remaining time to control the LEDs on the switch. As the time counts down the number and/or color of the LEDs change to give a visual indication of the remaining time from across the room.

                      Being very new to HS, I've got a lot to learn. As I'm unable to locate any published documentation there is going to be a lot of experimentation on my part to accomplish my objectives. With that said, help me understand, what is the issue with using timers? I would think that a timer and a wait statement is doing the same thing behind the scenes with the only difference being the timer is exposing the process to the user. Is this thinking incorrect? Is there a difference in performance? What is the benefit of using one over the other? Please help, Roger

                      After reading and re-reading before posting this reply I may have come up with a difference between the two. A wait statement runs for a finite time and returns control to a process whereas a timer runs and you have to keep checking to see if it reaches the required value before you can continue the process. Am I close?

                      Thanks,
                      Roger

                      Comment


                        #12
                        Originally posted by Roger D View Post
                        Greetings TC1, cc4005, et al.,

                        If I control my device as suggested how can I get the value of the delay time remaining?
                        You wouldn't be able to. As I said, I think your approach is reasonable for achieving your objectives.

                        Originally posted by Roger D View Post
                        Please help, Roger
                        I can't answer your questions confidently. As you're learning, there are typically a couple or, more often, several ways to accomplish the same thing with HS, and there are varying opinions on the "right" way. If you've not come across it yet, the event clinic subforum is a great place to find explanations of ways to accomplish many automation tasks as well as discussion of alternative methods and their relative merits.
                        -Wade

                        Comment


                          #13
                          A simple countdown timer would be so much cleaner with less ‘cancel this, cancel that’ which is completely non-deterministic.

                          I have a garage heater. By default, if I hit the switch or voice, I want it to run for 30 minutes. If the garage door opens, I want to take action, if the user wants linger or shorter, i want to take action.


                          the simplest way to do this is with a count-down timer. I have 1 timer ‘GarageHeaterRunTimer’.

                          When GarageHeater set on
                          if temp <50 and temp >32 Set timer to 30 minutes
                          If temp <=32 and temp >15 set timer to 1 hour
                          if temp < 15 set timer to 2 hours
                          start countdown
                          Control device GarageHeater to on


                          When GarageDoor is opened
                          Pause GarageHeaterRunTimer
                          CintrolDevice GarageHeater to off

                          when garage door closed
                          resume GarageHeaterRunTimer
                          Control device GarageHeater to on

                          when garage heater 1 hour triggered
                          set GarageHeaterRunTimer = 1 hr
                          start countdown timer
                          Control device GarageHeater to on

                          When GarageHeaterRunTimer = 0
                          Control device GarageHeater to off


                          Each action is completely encapsulated, and deterministic. You have limited inputs and only one outside state got check (timer) and 1 sentinel stop value (timer =0). The other methods are kludgy and unclear. Also, it’d be nice to look at HSBuddy and see 10 minutes remaining, etc…


                          I think countdown timers could really simplify a ton of workflows.

                          Comment


                            #14
                            I've asked for them so many times, I've stopped. NASA sort of launches rockets with countdown time. But I guess that it is rocket science.

                            Comment


                              #15
                              I’m actually wondering, what’s a use-case for an unbounded count-up timer (stopwatch)?


                              On garagedoor close
                              send push / speak garage door was open for $[timer]


                              i personally just see so many uses for a down count:

                              Start sprinkler1
                              if (last 24 hrs rain < x)
                              set timer to 5 min
                              start sprinkler1

                              if sprinkler1 has 1 minute remaining
                              set timer to 5 min
                              start sprinkler2


                              We think of automation in terms of doing a task for x time, when complete do y. The encapsulation possible with a simple timer is huge.

                              Comment

                              Working...
                              X