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

The used homeyscript flowcards can only return one local tag atm. You’ll have to make a request at Athom’s for adding an additional tag to those homeyscript flowcards.

But, we can use HomeyScript tags as extra step, but these tags are global, so I suggest using the stopwatch/timer name as tag name. You can add multiple HS tags of course if needed.

// Convert milliSeconds to HH:MM:SS as result, and to HH:MM as tag
//
// ENTER STOPWATCH or TIMERNAME
let timerName = "YourTimerNameHere"
// END OF USER INPUT

// -> argument: input in milliseconds
let milliseconds = args[0]
let seconds = milliseconds / 1000;

if (seconds == '' || seconds == undefined) {
    console.log ('Missing argument');
    return(false);
} else {
  d = seconds;
  var h = Math.floor(d / 3600);
  var m = Math.floor(d % 3600 / 60);
  var s = Math.floor(d % 3600 % 60);
}

  // Show as 'HH:MM'
  var clock_hhmm = ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2);
  // Show as 'HH:MM:SS'
  var clock_hhmmss = ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);

  // Create homeyscript string tag for clock_hhmm
  timerName = timerName + '_clock_hhmm'
  await tag(timerName, clock_hhmm);
  
// just for checks
console.log(clock_hhmm);
//console.log(clock_hhmmss);

return(clock_hhmmss);

I used ‘Koelkastinterval’ as timerName, and you can see the Homeyscript tag is created and available to use in other cards

1 Like