Display counter/timer in dashboard

dashboard
#1

Hi,

I need to fire a counter after a button is pressed and show elapsed time in a dashboard but I haven’t seen any widget that could address the timer issue. Also, I need to implement regular actions such as STOP, PAUSE, RESET functions.

I’ve thought a workaround, to use JS (this is a library example) in a custom webpage and embedded it as a widget in my dashboard. Are there any more straightforward solutions?

Regards,
Nahuel

#2

Hi there!

This is possible to do with Losant, but it is not an easy task. To make a stopwatch, you would need to create a new device to keep track of timestamps, and have three workflow paths for stop, pause, and reset. You would also need your dashboard to update once per second if you want it ticking live, but the Losant dashboard can only reload every 5 seconds at its fastest. Though it is possible, it is not a very straightforward solution and would not give you the same functionality as your library. My recommendation would be embedding in a block or an external URL as you will have more of the functionality you are looking for.

Thanks,
Julia

#3

Hi @JuliaKempf,

Thanks for your feedback. I’ll try with my workaround, then.

Regards,
Nahuel

1 Like
#4

Another approach would be.

When you press start, (send command to device - not a real device but a device that represents your counter).
You would start with a workflow that continuously fires every second.

In addition it would have endpoints for dashboard messages - Your START, STOP, PAUSE, RESET

Each time a message is recieved, set a global state value to the corresponding actions.

When each trigger event (timer) occurrs you then check the current global state, perform the action as a ppropriate

PAUSE - do nothing
STOP - probably no different to PAUSE
RESET - change the counter to 0.
START - (which means run) increment the counter

When the counter is incremented then write the new counter value to the device.

You can then use an indicator widget in with realtime stream from the device to show the counter value.

This of course means a Losant workflow is running continously :wink:

It would be nice to have control over the timer.

T

1 Like
#5

Hi @Tim_Hoffman, although your approach would also have the dashboard refresh issue (5 sec at its maximum speed as @JuliaKempf mentioned) it could work if you don’t need resolution of seconds from the timer.

I’ve thought a way of doing it but haven’t tried it yet. As the dashboard is embedded inside the layout, I could use the external library there to render the timer without having to sacrifice update rate and building workflows.

#6

Hi Nahuel

Actually it wouldn’t have a problem with refresh, The live stream indicator widget will update as data is Streamed in (ie counter incremented).

Only non streamed data would require refresh in your 5sec window.

#7

You are right, Tim.

Thanks!