Ubidots Community

How to: Display HOURS in a Metric Widget from last state CHANGE?

Easy question - I would like to show in a metric the number of hours since the last change of state. I am using for security on door sensors and motion sensors.

But I have no idea how to do this!

Hello @marlanw

I hope this note finds you well,

Here we have an example using a synthetic variable to calculate how long a variable remains in an ON state (1) which is determined by using the change of state to compute the time as you can see in the expression.
I invite you to look at it, test it and let us know if that works for you.

Regards,

-Santiago