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

**URL:** <https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214>\
**Category:** Apps\
**Tags:** app, official, tools, homey-pro\
**Created:** [September 17, 2019, 5:55am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214 "2019-09-17T05:55:42Z")\
**Posts on this page:** 20\
**Page:** 22

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [February 26, 2023, 11:04pm UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/435 "2023-02-26T23:04:39Z")

</div>

> [@Rrrr](#):
>
> can your script be modified to have two (or more) results (tags), for example:  
> // Convert milliSeconds to HH:MM:SS and HH:MM

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.

```auto
// 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

 ![Screenshot from 2023-02-27 00-49-12](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/0/101599d0d9df48b4e1328ee50d5f4ccfb7a10ba4.png)

---

<div class="post-metadata">

**Author:** ![Anders\_Gregow](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/anders_gregow/32/61721_2.png) [@Anders\_Gregow](https://community.homey.app/u/Anders_Gregow)\
**Post date:** [February 27, 2023, 7:45am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/436 "2023-02-27T07:45:01Z")

</div>

You could return a JSON string with as many results as you want, and parse them afterwards.

---

<div class="post-metadata">

**Author:** ![Rrrr](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rrrr/32/629_2.png) [@Rrrr](https://community.homey.app/u/Rrrr)\
**Post date:** [February 28, 2023, 8:13am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/437 "2023-02-28T08:13:47Z")

</div>

@Peter_Kawa Nice, thanks. By modifying your example I can actually output both strings as global variables as well. 🙏

> [@Anders\_Gregow](#):
>
> You could return a JSON string with as many results as you want, and parse them afterwards.

Thank you. I do not know how that can be done, it would be interesting to see, but if it would require more flow cards to parse the JSON string it’s less desirable.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [February 28, 2023, 8:18am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/438 "2023-02-28T08:18:39Z")

</div>

> [@Rrrr](#):
>
> Thank you. I do not know how that can be done, it would be interesting to see, but if it would require more flow cards to parse the JSON string it’s less desirable.

With the JSON handler app, you would only need one flowcard after each HS card, because you can read multiple json properties within one flowcard:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/f/ef9844de1e93bdf8dd3be1875e51151d147fc9bb.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [March 1, 2023, 12:44am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/439 "2023-03-01T00:44:20Z")

</div>

Thanks Arie, (and Anders for the idea).  
It still took me a while to get it going with script vars 😅

@Rrrr  
The script end part now like this, I made a JSON with the available clock values

```auto
  // Show time as 'HH:MM'
  var hh_mm = ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2);
  // Show time as 'HH:MM:SS'
  var hh_mm_ss = ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);

return(JSON.stringify({'hh_mm_ss':hh_mm_ss, 'hh_mm':hh_mm}));

```

The flow looks like this, the build in logic cards can parse JSON as well, so use what you like.

 ![Screenshot from 2023-03-01 01-45-23](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/e/6e60a563e47a4c1c863a5d25179ddc91df396ebc.png)

---

<div class="post-metadata">

**Author:** ![Rrrr](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rrrr/32/629_2.png) [@Rrrr](https://community.homey.app/u/Rrrr)\
**Post date:** [March 1, 2023, 8:14am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/440 "2023-03-01T08:14:16Z")

</div>

@Peter_Kawa [This](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/435) does not work for me: the Homeyscript string variables (tags) are not being created, or if I create them, they are not being filled. Any tip?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [March 1, 2023, 7:27pm UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/441 "2023-03-01T19:27:49Z")

</div>

Did you enter a timername on line #4?  
Say you entered a timername like, ‘fridge’.  
Then a Homeyscript tag should be created named ‘fridge\_clock\_hhmm’  
Just to be clear, the build-in Logic variables has nothing to do with this:

 ![Screenshot_20230301-202951_Firefox](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/3/835d161f9698d05875e51afc42f1de53a8f540ba.jpeg)

---

<div class="post-metadata">

**Author:** ![Rrrr](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rrrr/32/629_2.png) [@Rrrr](https://community.homey.app/u/Rrrr)\
**Post date:** [March 3, 2023, 10:54am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/442 "2023-03-03T10:54:58Z")

</div>

Found it (note that double quotes are required, like in your initial example:  
let timerName = “YourTimerNameHere”). I looked in the wrong place by checking under Variables (Logic variables). I guess that the global variables can only be found within a flow card? How do I remove a global variable?  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/5/d55cb61ee981cb5ae0f815cd1bd65ce1fa0a20ac.png)

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 3, 2023, 1:53pm UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/443 "2023-03-03T13:53:53Z")

</div>

> [@Rrrr](#):
>
> Found it (note that double quotes are required, like in your initial example:

@Peter_Kawa

# In [test](https://homey.app/a/nl.fellownet.chronograph/test/) and review now:

Duration and Elapsed (if applicable) tags are now available as HH:mm:ss and mm:ss.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/9/8958045fa66b6a99df290e7b0fd263f80f3b80d8.png)

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/1/6161b27078c7235bc65571da60fc9fbb0f44a29a.png)

---

<div class="post-metadata">

**Author:** ![Rrrr](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rrrr/32/629_2.png) [@Rrrr](https://community.homey.app/u/Rrrr)\
**Post date:** [March 3, 2023, 4:02pm UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/444 "2023-03-03T16:02:51Z")

</div>

That’s fast!

Comment: As one cannot know the elapsed duration in advance, leaving out the HH feels not right. Usually I would need either HH:MM:SS or HH:MM when seconds do not matter.  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/7/d700877b97040e40b3edda1f0bc98b53dd4ba01e.png)

Testing now…[deleted] the results are good, so all good!  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/f/0f3e5f3b82e16c7c8b46d7aeaf9d27ebde061328.png)

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 3, 2023, 4:15pm UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/445 "2023-03-03T16:15:10Z")

</div>

> [@Rrrr](#):
>
> HH:MM

Okay, one moment…

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 3, 2023, 4:21pm UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/446 "2023-03-03T16:21:57Z")

</div>

> [@Rrrr](#):
>
> it’s just a typo in your card text,

Where?

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 3, 2023, 4:22pm UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/447 "2023-03-03T16:22:33Z")

</div>

And, next version is in test now: extra cards with Hours (short): `HH:mm`.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [March 3, 2023, 10:19pm UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/448 "2023-03-03T22:19:37Z")

</div>

Looking good, Arie!

 ![Screenshot 2023-03-03 at 23-17-37](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/a/ea2e858bc9764b21be3a2bf77b4b5527041c4eb4.png)

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 8, 2023, 7:15am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/449 "2023-03-08T07:15:39Z")

</div>

## Update 1.5.1

- Bugfixed from old and new Crash reports.
- Added a Round Of for GetDuration tags.  
This can be configured in the app settings:  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/5/55a2d0316d2561e08a568ffcc1efef241da052db.png)  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/b/0b66dc18daf008eab131032f57d7245642baa72c.png)

---

<div class="post-metadata">

**Author:** ![Bjorn-Otto\_Samuelsen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bjorn-otto_samuelsen/32/71349_2.png) [@Bjorn-Otto\_Samuelsen](https://community.homey.app/u/Bjorn-Otto_Samuelsen)\
**Post date:** [March 8, 2023, 10:53am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/450 "2023-03-08T10:53:13Z")

</div>

After the last update I get this error: “Elapsed is not defined” on get elapsed card  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/3/0347e3ad978d5bf25f6c70ca60f0a14b88ebc078.png)

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 8, 2023, 11:07am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/451 "2023-03-08T11:07:55Z")

</div>

Okay, the fix for this is live: 1.5.2

---

<div class="post-metadata">

**Author:** ![Bjorn-Otto\_Samuelsen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bjorn-otto_samuelsen/32/71349_2.png) [@Bjorn-Otto\_Samuelsen](https://community.homey.app/u/Bjorn-Otto_Samuelsen)\
**Post date:** [March 8, 2023, 11:15am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/452 "2023-03-08T11:15:10Z")

</div>

New error  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/7/27e452ebc21d0f209745583553ae1c61dddbd6fe.png)

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 8, 2023, 11:35am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/453 "2023-03-08T11:35:00Z")

</div>

Weird, i understand why the error is there, i just cannot replicate the issue on old or new homey…

Solving it tho.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 8, 2023, 11:38am UTC](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214/454 "2023-03-08T11:38:36Z")

</div>

> [@Bjorn-Otto\_Samuelsen](#):
>
> New error

Update to 1.5.3?  
And lett me know if it works now, because i personally do not get the error message you get.  
Altho i did respond the results as text, which is now fixed to Number again.

Meaning also, f.i. if time is 0.40 hour, it is now a correct number again with 0.4 (missing the trailing 0).

[Previous page](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214.md?page=21)

[Next page](https://community.homey.app/t/app-pro-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214.md?page=23)
