How long a switch was ON today


i am trying to find a way to know how long the TV was turned on all Over the day till now.

my swich is persisted in influxdb.

The goal is to display a text item like : 2H43M

Any Ideas how to tackle it?

1 Like

A “cheating way” is to persist every minute, and then add up all records.

See persistence docs. Try making use of
Gets the previous State of a persisted Item, skips Items with equal State values and searches the first Item with State not equal the current State (returns HistoricItem)

Wouldn’t item.lastUpdate tell you? Assuming it always goes on/off/on/off