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

Glenn,

Do you also have Timer reached … with a variable in it?
Like this:

Because, if so, that never worked before right?

@Ronni ,

Indeed, and, unfortuancly, this cannot be solved for Variables.
Well, not without including the Athom-API (which is very memory heavy).

In your example:

Image 1 And-card: all the app does here is evaluated ALL When Timers flowcards with the given Name.
Then Homey will evaluate each card to check wether to really execute the flows.
There the name is checked based on the content of the token(variable in this case) and executed (or not).

Image 1 Start card:

Here the App gets the value of the variable, and then i can start the timer.

Image 2:
When Any Timer is done, all Timer-When cards are evaluated to be executed.
I give the TImer name and Homey the token/variable/text value.
I evaluate this and if the are the same, the flow is executed.

Image 3:

Whenever you save a flow with this card, the app gets a signal.
The app then saves the names and reached-info from the cards.

But when you use a variable/token, i cannot read that: i get a name like [[homey:app:logic|****]].

And i cannot read the inside/value of a (random) tag, without requiring full access to the Homey-Api.

This would be a terrible overhead, and create much checkups when running any(!) timer.
Or i would need to watch all variables/token that is/are used within each flowcard.

When you use the Timer/Stopwatch reached … with a direct name, that works fine.
Just not when you use a token/tag/variable with a name in it.

That is currently not possible for flowcards that have arguments that the app needs to know and match with a specific variable (like the “split”/reached time).

Thank you very much for the explanation! It’s not a big deal, and I agree, that it’s overkill to implement the entire Homey API just for that.
Maybe you could implement timer names in the Chronograph config, but that’s a different story, and propably a big rewrite of the entire app!

1 Like

I love the app. Just wish I could somehow grab the time state from a counter and, for example, put it in a variable or send it in a notification.

1 Like

Hi @GibStorm,

Not exactly what you were looking for, but it triggered me to create a script/flow/device for that purpose.
You can find importable flows for a Timer, and for a Stopwatch

Flow example:

AVD device:
Screenshot from 2023-01-05 16-53-49

Script (use it with Homeyscript flow card “Run code with argument, and return number-tag”):

// Get value (milliSeconds) of a running timer; Argument = timer name.

var timerName = (args[0]);

	let app = await Homey.apps.getApp({id:'nl.fellownet.chronograph'});
	app.apiGet('/timers/').then(result => {
		let timers = JSON.parse(result);
		timers.forEach(timer => {
        if ( timer.name == timerName ) {
		      app.apiGet('/timers/' + timer.name);
					// create/update tag [timername]_duration
          global.set(timer.name + "_duration", timer.duration);
          //// just a check for timer name:
          //console.log("TimerName: " + timer.name + " - Duration: " + timer.duration);
        }
  	  });
	});	
const timerDuration = global.get(timerName + "_duration");
return Number(timerDuration); 
1 Like

I’ll also work on a flowcard with token.
Can you make a feature request at the support link in the app store? Thanks!

I optimised your code with chatgpt :joy::joy:

// Get value (milliSeconds) of a running timer; Argument = timer name.

async function getTimerDuration(timerName) {
let app = await Homey.apps.getApp({id: ‘nl.fellownet.chronograph’});
let timers = JSON.parse(await app.apiGet(‘/timers/’));

for (const timer of timers) {
if (timer.name === timerName) {
global.set(timerName + ‘_duration’, timer.duration);
return Number(timer.duration);
}
}
}

const timerDuration = getTimerDuration(args[0]);
return timerDuration;

2 Likes

:stuck_out_tongue_winking_eye: I hate that kind of bots :laughing:
I’m at coding level: “damn, it works after just one weekend, now don’t touch it” :sweat_smile:

5 Likes

hi, sorry for the late response.
I have it like this. The red arrow starts the stopwatch.
The green one does not activate.

I just use normal delays in the meanwhile, but it would be nice if it could work the normal way.

Ohhh and I checked. The stopwatch runs as it should so the problem really is with the green arrow.

1 Like

Hei
Not really sure what I am doing wrong. I have a few flows that should start stopwatches but nothing is happening.

When I “install the devices” and click on one of these stopwatches its like I cant start them. I would press the “start/stop” button and they d just blink but nothing would be started. Really weird.

I have no flow that would prevent any stopwatch from starting… I have tried to restart the app a few times without any effect. Help is appreciated :slight_smile: thx

1 Like

No need for installing devices for using timers/stopwatches/transitions

Just make sure you use unique names for your timers/stopwatches/transitions

1 Like

Yes I know, I have installed the devices afterwards only to check what was going wrong.
Their names are unique.

1 Like

Upload your flow for us to have a look at it.

1 Like




I do get a notification in the timeline from PS_Step_0 but nothing related to stopwatches seems to happen thereafter.

1 Like

Have you looked in the Chronograph-app’s settings page to see if the stopwatches are running when expected?
Is Elwof home and charging? Print something to the timeline (Simplelog is very nice for logging BTW) for all then-else to see what is going on.

I do not think PS_Step_2 will work. If I remember correctly it is not possible to have a dynamic time-check in the when-card.

1 Like

Ps step 2 will not work: the duration has reached cannot be given a tag/token.

1 Like

Thanks all.
The Tesla app wasnt providing reliable data about the car, so I have set a condition on the EV charger power instead.
And yes the step 2++ flows did not work as I used a variable in the duration.

This now seems to work. Thanks!

1 Like

Hi Arie, any idea about my post yet?

1 Like

Which one?

Now in Test:

New flowcards:

Retrieve the (elapsed) duration of timers, stopwatches and transitions.

You will get Number tokens if applicable:

  • Duration (ms)
  • Duration (Seconds)
  • Duration (Minutes)
  • Duration (Hours)
  • Elapsed (ms)
  • Elapsed (Seconds)
  • Elapsed (Minutes)
  • Elapsed (Hours)

image

5 Likes