This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

[Published] CountDown timer (1.0.6)

aloftaloft Member
edited November 2017 in Apps

Homey CountDown timer

This is a CountDown timer which you can use to initiate flows.

Examples: When motion is detected, turn on light and start a timer for 90 seconds After 11 seconds, when motion is detected again, restart the timer for 90 seconds When the timer reaches 0, there was no motion for 90 seconds, turn off the light.

Settings

After installing the application, first visit the Homey Settings and navigate to the 'CountDown' application.

There you can add CountDown timers.

If you see a value '-1', this means the countdown timer is not active and waiting to be set ( via an action card in the flow )

Flow support

Triggers

There are 4 triggers - When a CountDown timer reaches 0. This will be the most used trigger. - When a CountDown timer has started - When a CountDown timer has stopped before reaching 0. - When a CountDown timer has changed its value

Actions

There are 3 actions:

  • Start CountDown timer: set a value and a number (in seconds)
  • Start random CountDown timer: set a value and a range (inclusive); when action starts, it will randomly selected a number between 'min' and 'max' (including those numbers) and start the CountDown timer
  • Adjust CountDown timer: increase or decrease (with negative numbers) a running CountDown timer
  • Stop CountDown timer: the CountDown timer will be stopped (and reset)
  • Stop all CountDown timers: All CountDown timers will be stopped (and reset)

Conditions

There are 2 condition cards:

  • Timer is (not) running: check whether a timer is running (or not)
  • Timer is (not) exactly value: to be used in combination with the 'value changed' trigger card. You can use this to check if a CountDown timer has reached a certain value.

Speech

No speech support

Acknowledgement

The CountDown timer is heavily influenced and inspired by the BetterLogic app. https://apps.athom.com/app/net.i-dev.betterlogic

The Condition card was suggested (and code provided) by GeurtDijker

The Start/Stop triggers cards were suggested by MarkSwift

Import / Export code by Patrick Sannes ( Better Logic app )

The trigger/condition combination for checking a value was suggested by YvesGeffens

Readable format of timer dates in settings menu was provided by jghaanstra

Donate

If you like the app, consider a donation to support development
Paypal donate

ToDo

  • Clean-up code
  • Translation to NL

Known bugs

  • Settings screen doesn't always update if a countdown timer updates
    • Workaround: Click 'CountDown' again in left-bar, after this, page will update when a timer is running

Changelog

  • V1.0.6 2017-09-27 : Add 'adjust timer' action card
  • V1.0.5 2017-09-27 : Add 'stop all timers' action card
  • V1.0.4 2016-12-20 : Human readable format for LastChanged dates in settings menu
  • V1.0.3 2016-12-05 : Fixed bug for tokens in action card when CountDown value changed
  • V1.0.1 2016-11-16 : Added trigger/condition combination to check value of a CountDown timer
  • V1.0.0 2016-11-01 : Added start/stop Countdown trigger cards, implemented export/import
  • V0.2.0 2016-07-20 : Added random CountDown action card
  • V0.1.0 2016-05-20 : Added condition card, fixed app for 0.8.35 compatability
  • V0.0.3 2016-04-18 : Optimized memory & cpu usage: the memory leak shouldn't be occuring anymore
  • V0.0.2 2016-04-16 : Optimized settings screen
  • V0.0.1 2016-04-15 : First public release
«134

Comments

  • I like the idea! 
    I hope it would be possible to start a timer if a door opens.
    so if longer a a minute that homey can set the thermostat to 15 degrees 
  • aloftaloft Member
    jovink said:
    I like the idea! 
    I hope it would be possible to start a timer if a door opens.
    so if longer a a minute that homey can set the thermostat to 15 degrees 
    That's the exact use-case for this app. So then you need these flows with this app:

    When [door opens] -> Then start timer door-open  with 60 seconds
    When [door closes] -> Stop timer door-open
    When timer door-open is 0 -> Set Thermostat to 15 degrees

    You might want to use an extra flow or integrate it with 'door closes' to also reset the thermostat if door closes. 
  • p0ntsp0nts Member
    edited April 2016
    if door opens
      timer 20 seconds
    if door open or movement detected and alarm still armed
      alarm
    else
      nothing
  • But does it also support this?

    Movement detected
      timer 20 seconds
    (after 11 seconds)
    Movement dected
     reset timer to initial start (20 seconds)



  • aloftaloft Member

    But does it also support this?

    Movement detected
      timer 20 seconds
    (after 11 seconds)
    Movement dected
     reset timer to initial start (20 seconds)



    If after 11 seconds, movement is detected (triggered by a flow), you just set the timer back to 20 seconds and the timer will go from 9 back to 20 seconds. So no need to first stop the timer and then restart it.  So basically the first flow (movement detected -> timer 20 seconds) can be reused also for new movement detections. 
  • ok, great! Thanks!
  • Sorry but how i can install on homey without the app store,i want to use the timer for the motion sensor,thanks regards
  • UrandayUranday Member
    edited April 2016
    brot84 said:
    Sorry but how i can install on homey without the app store,i want to use the timer for the motion sensor,thanks regards

    See https://developers.athom.com/library/introduction/
  • aloftaloft Member
    Pending approval in the App Store, you could download the source from github , and install it via command line.

    E.g. on Unix-based systems:
    npm install -g athom-cli
    athom login
    athom project --instal /path/to/downloaded/source
    
    
    
  • aloftaloft Member
    CountDown v0.0.2 has been published. Any feedback is appreciated.

    One bug that is already encountered: there might be a small memory leak that will cause the app to crash over time, depending on the amount of timers and triggering of those timers.  I am investigating what the cause is.  
  • aloft said:
    CountDown v0.0.2 has been published. Any feedback is appreciated.

    One bug that is already encountered: there might be a small memory leak that will cause the app to crash over time, depending on the amount of timers and triggering of those timers.  I am investigating what the cause is.  
    Great, I will certainly try it (but I'm going to wait until you solve the leak issue).
  • can someone post a flow picture, I'm still struggling with the flows. I read about When door opens then... and so on and so on, but... How does that look in Homey flow? 
    Need some visuals to get this stuff.
    Appreciate it!


  • Please check @Athom 's YouTube channel and see the several videos Emile made. 
  • Thnx I will have a look
  • aloftaloft Member
    Version 0.0.4 has been released in the App store.

    - Optimized settings screen
    - Lower memory usage & CPU usage. This limits the impact on the memory leak for operational use, although in extreme cases (thousands of updates) you will still be able to crash the App. 

  • @aloft: "(thousands of updates)"? how is that?
  • aloftaloft Member
    @aloft: "(thousands of updates)"? how is that?
    If you start / stop many timers at the same time with each a high amount of 'seconds', you'll be able to crash the app. 

    Every second that a timer runs is an update. So if you run 15 timers in parallel; you'll have 15 updates per second, or 900 updates per minute. If you keep that up for an hour, the app will likely crash.   Under normal circumstances - a couple of timers, not running constantly - memory usage is limited and the app will function OK  ( as far as I can test ). 

    Athom, myself and other developers -who experience the same issue- are looking into this root cause issue. I am also checking if there is a work-around possible. 
  • aloftaloft Member
    @kasteleman  Good news! Athom might have found the issue with memory leaks in applications. This will be embedded in an upcoming release.  As soon as it is available, I'll stress-test the CountDown app ;-)

  • @aloft That is very nice to read. Until then i'm going to test it with my Living Colours in a flow for "softdimming" feature during "bedtime" ;)
    Upcomimg release is as firmware .31?
  • Unfortunately have to wait until next firmware. Can not install apps anymore: something went wrong message. After installing HUE, KAKU and Philips TV, can not install anything. Kodi fails also with same error
  • RonnemanRonneman Member
    edited May 2016
    On version 0.8.34. I cannot add any new timers anymore.

    I can add them in the settings but they are not saved when I leave the screen.
    Someone else has the same issue?
  • Ronneman said:
    On version 0.8.34. I cannot add any new timers anymore.

    I can add them in the settings but they are not saved when I leave the screen.
    Someone else has the same issue?
    This was mentioned on Slack. Seems to be a common issue for more apps (for instance adding a variable to Better Logic doesnt work either).
  • Hi @aloft ;;
    I was thinking about a "Debouncer" using your Countdown disabling and enabling flows:
    https://forum.athom.com/discussion/comment/22576/#Comment_22576 ;

    Is it possible to create a  Condition Card/ Condition  "Countdown [NOT] running"
    This saves a flow in the example like above. 

    I tested it locally and it works, see my pull request. 
  • aloftaloft Member
    Hi @aloft ;;
    I was thinking about a "Debouncer" using your Countdown disabling and enabling flows:
    https://forum.athom.com/discussion/comment/22576/#Comment_22576 ;

    Is it possible to create a  Condition Card/ Condition  "Countdown [NOT] running"
    This saves a flow in the example like above. 

    I tested it locally and it works, see my pull request. 
    I saw your pull request, I'll take a look at it. Right now, my Homey crashed within a couple of minutes after restarting, so I need to figure out what is happening or do a full reset.

    Thanks for the suggestion (and solution :-) )


  • aloftaloft Member
    @GeurtDijker ;
    I've implemented your suggestion (and changed it a little bit), but to test I need 0.8.35 , so it might take a day or 2. If you like to be contributed in the app.json file, send me a message with your email address, and I'll add you. 

    Thanks again!

  • aloftaloft Member
    Version 0.1.0 has been submitted for approval to the app store.

    * Added condition card ; so you can check if a CountDown timer is or isn't running in a flow
    * Fixed code for compatibility with 0.8.35 ; otherwise it won't save variables.
  • bvdbosbvdbos Member
    You're fast :smile: 
  • aloftaloft Member
    You're fast :smile: 
    All kudos to @Uranday  ; he found the issue in BetterLogic within minutes, I merely typed very fast to update CountDown's code.

  • Great work @aloft and @Uranday. Looking forward to setting up my flows again with both your apps!
    @Athom, priority lane please!  ;)
Sign In or Register to comment.