I’m writing a DH for an energy monitor in ST classic. I’ve already added some cost calculations and these create a new attribute “cost” that’s derived from the current value of kWh * costPerUnit that’s set by the user in preferences.
The next step is to add a resetDate and resetOffest. The idea here is you press reset and instead of resetting the meter’s internal reading, it just records the current date and meter reading.
In this way the cost can be calculated from the last reset date by subtracting the resetOffset and using the resetDate to calculate the standing charge aspect of the bill.
But I can’t find a “date” type for attributes or preferences.
I’d rather use an attribute or stored variable for resetDate and resetOffset, I don’t want them user configurable. I just want to create a method that sets these values to the current date and current meter reading when the users presses a tile.
What’s the best way to do this?