Timestamp whenever an item changes state

Hello community,

I am new in OpenHAB and i have a question,

Is it possible to save in a text file, the date when a certain item, for example a switch, changes its state? Would it be something implemented in a rule?

Thank you

Does it have to be in a text file? What’s it for?

You can use Persistence to store the state of a switch.

Or you could use another Item which follows your switch Item, and sets itself to a timestamp of the last update:

Hello hafniumzinc,

It doesn’t need to be a text file. What I want is to save the exact moment when an item changes state. In the case of an item switch, I want to save the timestamp of the change from ON to OFF and OFF to ON. That is, whenever there is a change of state.

Thank you.

If you are on OH3 then this is already happening

1 Like

Thank you, I’ll check it out!

Note that the default persistence service (rrd4j) does some averaging by default; as time goes by the time periods get bigger grained. Okay for approximate times over the last week, no good for second-by-second accuracy. Other persistence services bring other options.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.