I’m using the PersistenceExtensions: See my post here: Washing machine status widget - #3 by DrRSatzteil
You may also just reset an item to 0 when you enter MODE_ACTIVE and increase this number by one every minute while the current mode is still == MODE_ACTIVE.