Calculating cost from MQTT
I am trying to calculate the Daily, Weekly and Monthly cost of electricity and gas and although electricity seems OK, gas doesn't line up with what the IHD says (although I have figured out how out to get the value but not why)
At the time the electricity meter showed
Today - 7.3 kWh £2.33
This Week - 58.0 kWh £17.40
This Month - 271.7 kWh £80.29
The latest (approx) MQTT message https://gist.github.com/REBELinBLUE/c1f1d3bc9bf492a96d2ddbb04e28985e
Today = Standing Charge + (Unit Rate * Day) = 0.5783 + (0.24012 * 7.308) = 2.33309696
This Week = (Standing Charge * 6 for Saturday) + (Unit Rate * Week) = (0.5783 * 6) + (0.24012 * 58.026) = 17.40300312
This Month = (Standing Charge * 26) + (Unit Rate * Month) = (0.5783 * 26) + (0.24012 * 271.758) = 80.29399976
This all lines up, but with gas it doesn't, the meter says
Today - 4.4 kWh £0.57
This Week - 35.0 kWh £3.63
This Month - 171.3 kWh £17.92
The latest (approx) MQTT message https://gist.github.com/REBELinBLUE/fe4daacf0e91e65efdcccdc8278bfde6
Today = Standing Charge + (Unit Rate * Day) = 0.31392 + (0.0588 * 4.378) = 0.57399936
This Week = (Standing Charge * 6 for Saturday) + (Unit Rate * Week) = (0.31392 * 6) + (0.0588 * 35.028) = 3.9431664
This Month = (Standing Charge * 26) + (Unit Rate * Month) = (0.31392 * 26) + (0.0588 * 171.319) = 18.2354772
Today is correct but this week and this month are not, however I have realised if I don't include the standing charge for the current day it is (i.e if I multiply by 5 and 25 instead)
I can't figure out the reason for this, does anyone have any idea?