[APP][Pro] Chronograph - Adds precise timer, stopwatch and transition functionality to Homey

Chronograph

Adds precise timer- and stopwatch functionality to Homey.

Features

  • Create timers and stopwatches directly from flow cards, no need for a prior configuration,
  • Start timers with a duration in milliseconds (fractional seconds), seconds, minutes, hours or days,
  • Start stopwatches without a predefined end time,
  • Trigger flows at exact timer- or stopwatch durations with millisecond (fractional seconds) precision,
  • Self-explanatory flow cards for easy integration of timers and stopwatches in your home automation.

Old Readme file:

FEATURES

  • Self-explanatory flow cards for easy integration of timers, stopwatches and transitions in your home automation,
  • Create timers, stopwatches and transitions directly from flow cards, no need for a prior configuration,
  • Start timers with a duration in milliseconds (fractional seconds), seconds, minutes, hours or days,
  • Start stopwatches without a predefined end time,
  • Start transitions to gradually change a device parameter over time,
  • Trigger flows at exact timer- or stopwatch durations with millisecond (fractional seconds) precision,
  • Pause and resume timers, stopwatches and transitions with action cards or from within settings,
  • Support for random or computed durations or adjustments using simple math expressions,
  • All timers, stopwatches and transitions are persistent across Homey restarts,
  • Target multiple timers, stopwatches and transitions at once using wildcards in supported cards.

SIMPLE MATH EXPRESSIONS

The start, resume and adjust action cards have built-in support for simple math expressions. This allows for random or computed timer and stopwatch durations, including calculations based on token values.

For example:

ceil(99.5) / 5
pick(1, 3, 5, 9) * 2
random(10, 30)
abs(-10)

In addition to basic math expressions, the following functions are supported:

  • abs(x) - calculate the absolute value of a number,
  • ceil(x) - rounds a number up to the next whole number,
  • floor(x) - rounds a number down to the previous whole number,
  • round(x) - rounds a number towards the nearest whole number,
  • random(min, max) - a random number larger or equal to min and smaller than max,
  • min(x, y) - the lowest number from the supplied list,
  • max(x, y) - the largest number from the supplied list,
  • pick(x, y[, n]) - pick a random value from the supplied list.

HOMEYSCRIPT

In addition to the available flow cards, timers and stopwatches can also be controlled using HomeyScript.

For example, this script will stop all running timers:

let app = await Homey.apps.getApp({id:'nl.fellownet.chronograph'});
app.apiGet('/timers').then(result => {
	let timers = JSON.parse(result);
	timers.forEach(timer => {
		app.apiDelete('/timers/' + timer.id);
	});
});
  • GET /timers - retrieve a list of all active timers,
  • GET /timers/:id - retrieve a single timer,
  • PUT /timers/:id - pause or resume a timer,
  • DELETE /timers/:id - stops a timer.
  • GET /stopwatches - retrieve a list of all active timers,
  • GET /stopwatches/:id - retrieve a single timer,
  • PUT /stopwatches/:id - pause or resume a timer,
  • DELETE /stopwatches/:id - stops a timer.
  • GET /transitions - retrieve a list of all active transitions,
  • GET /transitions/:id - retrieve a single transition,
  • PUT /transitions/:id - pause or resume a transition,
  • DELETE /transitions/:id - stops a transition.

Please report issues or feature requests at QlusterIT / nl.qluster-it.Chronograph/ issues — Bitbucket.

Apps:

Donations or Sponsorship

it looks perfect. However I do have some questions:

  1. where can find remaining time of timer?
  2. Is it possible to use remaining time in notifications (didn’t find this label)?

Thanx

There’s actually a new version under review by Athom that has a settings page with an overview of all timers and stopwatches currently running.

That version also includes tokens (tags/labels) with the duration of a timer or stopwatch, but those are only available after a trigger. I have yet to find a good way to include global tokens (those that exist all the time, in every card). It’s not trivial because it would most likely require me to update these tokens every xx milliseconds for it to be even slightly accurate, which would give too big of a load/stress on a Homey.

Nice, tested and one more comment. If I do a app restart, or Homey restart, timer information is lost. This is quite a problem for long term running timers (e.g. watering delay in case of rain).

That’s exactly one of the new features in v1.0.2 which is currently being prepared for release (see the release notes on github).

Version v1.0.2 has just been released:

  • Timers and stopwatches are now persistent across application restarts and Homey reboots.
  • Pause and resume timers and stopwatches from flow cards.
  • Fine-tuning of the settings page.
  • Pause and resume timers and stopwatches from settings.
  • Support for timers longer than 24.855 days.
  • Unit testing.

How do I use the value of a stopwatch as a variable to make calculations?

Hi, I really want to use this app instead of countdown since this is much more promising. I was just wondering, is it possible to add a timer with a variable end time? (like somewhere between 600s and 1800s?)

That’s exactly one of the new functionalities I’m currently working on. To give you an idea, I’ve pushed this development branch to github, so you can take a look at the readme to see if it suits your needs. The new functionality is currently being tested by a select few alpha testers, and it will be offered as a beta to the Athom review team hopefully somewhere next week.

52

You are the man! This looks amazing!! The random setting is used to make it look like I’m present when I’m away or asleep at night, so that needs to be completely random between a min and max nr of seconds so I’ll only need that expression for that.

But, I also see great potential in all the other math expressions you will be adding, and even have som current flows that will be simplified by this, very nice!
I’m in stable release, because I read that switching from beta to stable would reset the entire application so I’ll have to wait a little longer! When do you think this wil hit stable release?

Two, maximum three weeks, max. Depending on problems that are discovered, and the time Athom takes to review the new release.

Sounds great!! I’ts worth the wait, that’s for sure :slight_smile:

Version 1.0.3 (stable) has just been released with the following change:

  • German translation, thanks to Copiis.

Version 1.0.4 (beta) has just been released with the following change:

  • Support for simple math expressions in timer and stopwatch durations.

Kudos to Athom for reviewing the beta version of the app within a day :wink:

Version 1.0.5 (beta) is offered for review and fixes a major import bug that causes crashes for version 1.0.4 (beta). Guess that’s why they’re called beta’s :grimacing:

Hello.
App 1.03 crashes when I use “start or replace timer X” while the timer X is already running.
I think it was working correctly (replacing running timer with newly provided value) in previous versions.
When I alternatively try “adjust timer X” also nothing happens to the value of running timer, but at least app does not crash.

It’s quite ambitious to have millisecond update of global tokens. I would appreciate the actual timer value as a global token even with seconds precision.
Good work, by the way!

Version 1.0.6 (beta) has just been released with the following change:

  • Added transitions to gradually change a value over time.
  • Tweaked support for simple math expressions in timer, stopwatch and transition durations.

If no issues arise, this will be the next stable release.

How can I use the Stopwatches with logic or better logic?
e.g. variable Xy = stopwatch Xy

There is no tag for stopwatches available in logic or better logic!

Do I something wrong?! Or is the answer very simple,
it’s no possible!

There’s a technical challenge here. Having tokens available whenever something unrelated triggered a flow is unfeasible. That would require the app to update tokens every few milliseconds to be somewhat precise. I could implement a work-around though. What if you could pause the timer once your event triggers, and then have a separate flow react on the pausing of the timer. At that point you’d have the exact duration of the timer in a token that you can use however you want. You can also resume the timer in the same flow. Would that help your cause?

I think that’s exactly what i’m looking for! :grinning:

What i want realize, is a kind of “Operating hours counter”.

I want to determined how long a specific device was turned on during the day. This is already possible with the Chronograph App but I can not store the result in a variable.

The Stopwatch should run everytime if the device is turned on and will be paused when it was turned off. End of the day i want to save the value of the Stopwatch in a varaiable. In this way it would be possible to visualize the “Operating hours counter” through insights.

Thanks a lot in advance!!