BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
570 stars 57 forks source link

First hour of cost tracker missing #844

Closed TransientWolf closed 4 months ago

TransientWolf commented 5 months ago

Describe the bug

My Import Cost Tracker has been wrong by a few pence compared to the energy dashboard since the change to BST in March. The attributes all track to GMT rather than BST. Because the cost tracker resets at midnight BST, not midnight GMT, it misses the first hour of the day (00:00-00:59 BST) and includes it in the previous day.

This seems to be different from the other time bugs as my target sensors all work fine. Just the cost tracker reset issue.

Reproduction steps

Set up a cost tracker and check the attributes to confirm that the rates are all mapped to GMT. Note that at midnight BST the cost tracker resets to zero for the day, rather than at midnight GMT.

Expected behaviour

Either the rates should be mapped to BST (which would be preferable as it would make reading the attributes much easier during March to October) or the cost tracker daily reset should be at GMT midnight not BST midnight (I assume this is HA driven?).

Tariff Code

Agile

Integration Version

10.3.0

Home Assistant Version

2024.04

Fresh Install?

Not specified

Home Assistant Logs

N/A

Confirmation

TransientWolf commented 5 months ago

The more I have looked at this the less sure I am that it is the time of the reset. What I do know is that the tracker seems to be missing about an hours worth of cost at any one time, and that seems to be the cost between 00:00 GMT and 00:00 BST. So it always under-reports.

BottlecapDave commented 5 months ago

Hello and sorry that you're having issues with the cost tracker. The sensor should update whenever the sensor updates that is being tracked. Therefore if it doesn't update during a given 30 minute period, there will be a "missing entry" in the cost tracker. The cost tracker will reset every day at midnight local time (so at the moment BST).

All rates within the integration are provided in UTC/GMT as this is what OE provide the data as. However I am looking at converting this data into local times for a future release.

Could you please elaborate on what sensor you're tracking the cost of and provide a screenshot of the updates within a certain day along with a screenshot or copy of the tracked changes in the cost tracker. Could you also elaborate on how the cost is being calculated in the energy dashboard?

TransientWolf commented 5 months ago

Hi. The Energy Dashboard tracks a Utility Meter which tracks my GivTCP Import Energy Today Sensor and for cost tracks the Octopus Current Rate from your integration (on an Agile tariff). The Cost Tracker tracks the same Utility Meter. The attributes for the Cost Tracker start with the 00:00 to 00:30 (and then 00:30 to 01:00) time slots which are GMT and therefore technically yesterday. The Energy Dashboard shows a higher number than the cost tracker for import every day. You can see the dashboard shows £1.21 and the Cost Tracker shows £1.09. The dashboard is the correct number verified back to my bills. The export tracker is correct - I assume because there is nothing happening export wise at midnight GMT or BST. Interestingly if you look at the movement in the utility meter between 00:00 and 01:00 you can see that it increases in line with consumption as you would expect, however the Cost Tracker doesn't - it flat lines for the first hour after resetting at midnight. It is as though it completely misses the first hour of the day for some reason, and this is also pretty much the amount that it is out, based on last nights consumption and the agile rate at midnight. Screen shots attached.

Grid Import Today at Midnight Grid Import Today at 1am Octopus Import Cost Tracker @ Midnight Octopus Import Cost Tracker at 1am Cost Tracker Import Attribuites Energy Dashboard Octopus Import Cost Tracker Configuration
BottlecapDave commented 5 months ago

Thanks for providing the overview. I'll see if I can recreate it locally.

BottlecapDave commented 5 months ago

I unfortunately don't have a utilty meter which updates as frequently as yours. Instead i've setup a cost tracker looking at the current accumulative conumption sensor which is correctly updating frequently after midnight.

Screenshot 2024-04-23 203237

Is it possible for you to tell me the value of the tracked sensor at 00:00 and 00:15, 00:30 and 00:45? I'm just wondering if the utility meter isn't updating at the correct intervals.

TransientWolf commented 5 months ago

It updates every time there is a 0.1 increase in consumption which for the period above was as per screenshot 1 and for last night when it started charging my battery during the period as per screenshot 2. As might be expected because it was charging last night during that period this morning the two sensors are massively out.

I will set up a cost tracker linked to the source underlying the utility meter directly and see what happens tonight.

Cost Tracker Update Screenshot Cost Tracker Update Screenshot 2
TransientWolf commented 5 months ago

If I track the underlying sensor directly I get the same issue - pic below shows test cost tracker on top and the underlying sensor on the bottom. Am I doing something wrong with the accumulative check box - i have it ticked because it accumulates right?

Screenshot 2024-04-25 at 10 27 42 Screenshot 2024-04-25 at 10 32 17
BottlecapDave commented 5 months ago

It doesn't look like you're doing anything wrong. The cost tracker looks like it goes up slightly between 00:00 and 01:00. Could it be the costs are so low that the consumption cost is minuscule? If you could

If you are comfortable, it would be best to be on the v11.0.0-beta1 when doing this, as this has richer logging around the cost tracker, but the latest stable release should also give some good hints at what's going on.

TransientWolf commented 4 months ago

OK. So I updated to v11.0.0-beta1 last night and enabled debugging but noticed this morning the cost tracker was working correctly! I see in the target rates attributes they now show BST time with a "+ 1 hour" which is perfect and so much easier to read without adding an hour on in my head. And for some reason seems to have fixed whatever the issue was with the cost tracker. Won't bother posting the debug file.

BottlecapDave commented 4 months ago

hmm very odd as nothing really changed in how the data is calculated in that release with the cost tracker. The only real change was in how the attributes are reported back. But I'm glad it's working with this beta release.

TransientWolf commented 4 months ago

Thanks for investigating. Will close and reopen if it comes back but so far all been fine.