How to create a live count down? For example, a user will select 20 mins, I want to create a live countdown. I have no idea how to start this hence I am looking for guidance on a solution for this.
The reason I want to do this:
I want to shelve alarms using system.alarm.shelve() and provide the user/operator a live countdown of the alarm for when it will be unshelved automatically
You can create a live countdown by storing the selected duration (e.g., 20 minutes) and the start time (system.date.now()) in custom properties or tags. Then, calculate the remaining time by subtracting the current time from the end time using an expression or script. Use a Perspective Timer component to update the display every second. Bind a label or LED display to show the formatted remaining time as HH:mm: ss. When the countdown hits zero, you can trigger any follow-up action, such as ending the alarm shelf period.
an integer derived (or expression ?) tag that would use now(1000) and dateDiff to calculate the number of seconds between now and the target. You can always reprocess that integer to show hours, minutes and whatnot for display purposes
You should definitely use tags for this as @pascal.fragnoud mentions, not a timer event script. Tags are far simpler to configure and add to, but more importantly, are more efficient and performant as well