Closed 5iver closed 3 years ago
The root cause for this issue is that persistence in general is not ready for UoM (see e.g. https://github.com/eclipse/smarthome/issues/5675#issuecomment-396184230). The units are not persisted in legacy persistence add-ons in openhab1-addons. I think https://github.com/openhab/openhab-addons/pull/5275 will change the situation and we can enhance some persistence services.
Will be fixed once this feature has been implemented in all persistence add-ons (see #1954 for more information).
When using PersistenceExtensions.previousState(true) with an Item that uses QuantityType, it always returns the current state, since historicItem.getState() will never be a QuantityType...
https://github.com/openhab/openhab-core/blob/master/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/extensions/PersistenceExtensions.java#L704
Is this a bug or by design? I notice the test doesn't do anything with QuanityType for previousState, so I'm thinking bug.
I simple test is to enable persistence, add an Item without Dimension, add data, then compare previousState(true) to the current state. They will be the different. Now, add a Dimension to the Item and previousState(true) will be the same, without even changing the data.
Without Dimension...
With Dimension...