Count Up or Down Timer, Custom tile

OK, I think I know the issue. Its switching the from Weeks+days to days only if < 1 week, and so on if < 1day to hr only and the order is wrong so if the hour unit is <1 it wont print the weeks or days. Give me some time to figure and correct it.

The issue should be fixed now. And when you select weeks+days if it gets to <1 week it will change to days+hours and so on. Same for the days+hours, if < 1day it will go to hour+min. You need upload latest code. Delete the old custom tile HTML and hit that link again, or see if that update thing works which I cant seem to find.

1 Like

Great thanks - I’ll update now

@kampto I updated and the display shows correctly in weeks and days. I think something may still be amiss however. I’ve set the new tile to a target date time as shown:

It displayed when set at 6 Weeks 6 Days which was correct at the time but it is not counting down - so is still showing the same after a couple of days.

Fixed. Go to the HTML page and hit this settings icon. Should be a download latest option, select that and save/update, you should be good to go.

image

2 Likes

Yup - that fixed and immediately knocked the two days off. Thanks so much. :+1:

1 Like

@kampto - Thanks for the improvements! A little fiddling and it does everything I wanted.

@kampto What might be good (not sure what it would take to code), would be a default event/date setting. Use case:

I have a Countdown Timer tile on 3 separate dashboards. This is the first one I’ve used and the date and time for my trip which I’d set finally came around, the timer expired and the message appeared as set - all good. I’ve got nothing planned at the moment (unfortunately) that warrants setting on the tile, but the tiles are showing the expiry message (default or otherwise). I wondered if it would be achievable to have a “default date on expiry”. This would be another event/date of choice that would replace the first after expiry (until another is set) - it could be anything that repeats the same day each year - Christmas, a birthday etc. It would save changing the tile settings on each dashboard or removing it and replacing it with a spacer until needed again.

1 Like

I will look into the default date.

1 Like

I’ve added some more capability in the Tile editor:

Main content vertical position. This adds the ability to move the content up or down in the tile. You will have to adjust it based on your font size. If you enter nothing it will be centered.

Show Reset Button. This adds a reset button on the bottom of tile. If the tile is Counting Up then it will reset the count to now and restart from 0sec. If its Counting Down the it will reset the counter to the second target date. So if your timer expires, hit the reset button and it will go to the Count Down Timer Next Target date that was entered which could be some arbitrary date like new year day. Essentially clearing the Expired message.

Make reset button transparent. Visually hides the button but its still there and functional. Mouse over it. Need to check show reset button first.

Display expiration target date. Displays target on bottom of tile.

image

On mouse over hidden reset button example:
image

To Update go to developer tools custom tiles, Count Up/Down Timer. Hit the gear icon and update.
image

Or click the Count Up/Down Timer link in post #1 and re-add tile.

3 Likes

@kampto - awesome work, thanks. I’ll give it a try.

I think for your case you will want to add the reset button, hide the rest button, then enter the second Target date at the bottom of tilt editor. After your 1st date expires and you see the expiration message, hit the hidden rest button to switch to the next target date.
Of course if you refresh the browser it will revert back to the 1st target date until you hit reset again.

1 Like

Yes thats what I’ve done. It works great - thank you :grinning:

@kampto, just doing a little day-dreaming…

I’ve often wanted a periodic timer that could fire an event. For example - every N seconds a change occurs that can be used by a rule to do something.

IF (1) you could trigger an event when your timer counts down to zero,
AND IF (2) you could then restart your timer for N seconds it seems that we would have such a device.

Perhaps (1) could be accomplished with style states.

OK - it’s obvious that I don’t know what I’m talking about, but I think a timer like this would be very useful.

That would be sweet for sure. As far as I know there’s no way to link a custom tile value or state to a style or rule. Maybe the pro’s can add some insite, @josh , @James

1 Like

I’m not sure how a style would help for triggering a rule / event unless it was tied to a device. For purely visual needs, I usually just have the Custom Tile change its own style based on its own state.

For an external trigger, you could have a Custom Tile control a device via API or even execute a SharpTools rule that has an HTTP trigger. The challenge here is that the Custom Tile runs in your browser which has several implications - if the browser’s closed it’s not working, and if multiple copies of the dashboard (or tile) are displayed then they will all trigger.

Usually this kind of timer/triggering logic is handled in a central place (eg. on a hub, in a device, or in a rule). Another community member was playing with the ‘Timed Session’ device capability in Hubitat to do something similar to this at one point, IIRC. They were able to set a timer in a device and then ‘start’ the timer… then when the timer ended, that device could act as a trigger for rules.

1 Like

I am looking for a slightly different kind of timer. My use case is STHM or similar. I want the tile to show a STHM icon as inactive. When I tap, I want a timer to show a count down for 60s and then I want the icon to switch back to active (glow). What is missing is that timer component. Is there any way to achieve that? Ideally with native tools, rather than a custom tile.

I made a variable with a dashboard rule that changes daily using math expressions. Maybe you can adapt it to your needs. Tapping in the dashboard tile resets the variable to a predefined number of days.

Daily Rule

Variable tile

Dashboard Rule to reset variable

Is it possible to start or stop the timer from a rule? Or set the amount of time it counts down from? Thanks.

I haven’t been able to figure a way to overwrite whats manually entered in the tile editor remotely or with a button. For instance I have a count up tile with a reset button on tile and it works to Zero the counter but when the browser is refreshed it reverts back to what’s in the tile editor.
image

There’s a feature request for custom tiles to have access to platform resources and other. This would open up a lot of possibility’s.
Make “Custom Tiles” have access to platform resources like Variables and Things - Feature Requests - SharpTools Community

Could you make a Supertile and do what you want?