Issue of the topic: I try to calculcate the hourly average power consumption of my HS110 socket. Therefore I save every 15 minutes the current power usage into my MariaDB database. So far so good. Now I try to calculate the hourly average consumption with a rule that looks like this:
rule “Socket01_hourlyConsumption”
when
Time cron “0 0 * ? * *”
then
Socket01_hourlyAverage.postUpdate(Socket01_power.averageSince(now.minusMinutes(60)))
end
*In reality the rule is a little bit longer. For reasons of comprehension I removed all unnecessary parts.
Let’s have a look on the tracked 15 minutes results:
2019-12-21 08:45:00.902 - 0 Watt
2019-12-21 09:00:01.029 - 0 Watt
2019-12-21 09:15:00.211 - 0 Watt
2019-12-21 09:30:00.339 - 0 Watt
2019-12-21 09:45:00.481 - 207.266 Watt
2019-12-21 10:00:00.593 - 211.374 Watt
And the result of the rule looks like:
2019-12-21 10:00:00.413 - (-131.0962113148697)
How is that possible? The rule should have calculcated (0+0+0+207,266)/4=51,82
Do I get something wrong? Is there an obvious mistake somewhere?
Thanks in advance!
yeah - my rule triggered before the variable for 10am was written to the database. But that should be no problem?
So i assume that my rule triggered around 10:00:00:00-10:00:00:412 am. Therefore it should have been used the variables within the last 60 minutes:
2019-12-21 09:00:01.029 - 0 Watt
2019-12-21 09:15:00.211 - 0 Watt
2019-12-21 09:30:00.339 - 0 Watt
2019-12-21 09:45:00.481 - 207.266 Watt
And the result should be (0+0+0+207,266)/4= 51,82
But the actual result is completely wrong -131.0962113148697. How is it possible that it calculated a negative average?
Thank you! After some long time I came back to this problem and of course it was a timezone issue. I’m running openhab on a Synology Docker and changed the timezone to CET. Since that change it’s working without any problems
Sorry for the late response. I am operating openhab in a docker container on my Synology DS. Therefore, I cannot set the timezone as I’m used to it in a “normal” linux system. So at the beginning it was too complicated for me to change the timezone within the docker container to Standard European Time (CEST).
Fortunately there is an environment variable you can set to change it. I have written a little how-to for this case (in german). For other who have the same problem, you can have a look to this: https://schweigerstechblog.de/openhab-2-synology-docker-timezone-aendern/
If it’s not allowed to post a link in this forum, just delete it please.