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
@Peter_Kawa Nice, thanks. By modifying your example I can actually output both strings as global variables as well.
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.
@Peter_KawaThis 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?
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:
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?
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.
Testing now…[deleted] the results are good, so all good!
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).