Hello,
I’m new to openHAB, and I’m trying to better understand how persistence data works. I have a solar inverter, which reports a parameter called Autonomy. It is of type Number:Dimensionless, and during the day, it is usually 1.
When I run the following script (application/javascript;version=ECMAScript-2021), I get an output that seems inconsistent to me. As far as I can tell, these three values that I print to the log should all be 1. Is anyone able to help me understand where I am going wrong?
"use strict";
(function() {
console.info('start test script');
const powerAutonomy = items.getItem('FroniusSymoInverter_Autonomy');
const twoMinutesAgo = new Date(new Date().getTime() - (2 * 60 * 1000));
console.info(powerAutonomy.history.minimumSince(twoMinutesAgo));
console.info(powerAutonomy.history.maximumSince(twoMinutesAgo));
console.info(powerAutonomy.history.averageSince(twoMinutesAgo));
console.info('end test script');
})();
openhab.log:
2022-12-08 11:33:18.644 [INFO ] [nhab.automation.script.ui.e1d457cd25] - start test script
2022-12-08 11:33:18.645 [INFO ] [nhab.automation.script.ui.e1d457cd25] - 1
2022-12-08 11:33:18.647 [INFO ] [nhab.automation.script.ui.e1d457cd25] - 100 %
2022-12-08 11:33:18.648 [INFO ] [nhab.automation.script.ui.e1d457cd25] - 8.779954150091026
2022-12-08 11:33:18.648 [INFO ] [nhab.automation.script.ui.e1d457cd25] - end test script
Thank you for your help!
Stuart
(edited to remove unnecessary code)