Energy Cost Calculation went haywire after 2022.8

I can see at least 5 resets on this graph.

1 reset on the 4th.
2 resets on the 7th.
2 resets on the 8th.

You’re right! I checked the chart and all resets went to 0 for the import.

Those number look correct for today right?

I’m not sure what it’s supposed to look like. But the cost on the dashboard is still wonky.

ballpark they look about right though.

If you search in developer tools>states for $474.20 (or whatever the current value is) or alternatively just for “compensation” do you find another sensor with that incorrect value?

If you can stomach starting from scratch I think the easiest fix is to edit the energy dashboard and delete the current import and export sensors from it. Restart HA then add them a back in. I think HA is hanging onto an old or incorrect sensor for an unknown reason. Did you change the energy dashboard configuration at all recently?

I’m unable to find any thing in developer tools>states with the $ or any combo of -$474

I’ve change all sorts of things back and forth for a couple weeks now trouble shooting, and have already lost a lot of data. Hoping I can figure out how to import it from my utilities export or a Enphase export at a later date. :crossed_fingers:
I was thinking of spinning up a fresh DB. Would that help HA lose a incorrect association it’s making?

Yeah sorry it won’t start with $, just the numbers, try 47

I was thinking of spinning up a fresh DB. Would that help HA lose a incorrect association it’s making?

Yes that is one solution, deleting the DB.

The energy dashboard stores data in a column called sum in table called statistics.
It records the difference in the value of the sensor every hour (as state column) and and then adds that difference to the sum column.
Statistics update hourly.

I have SQLite web add on installed

Here is the query I used to display the table below.

You will need to find the correct id’s for your own sensors by first displaying the content of the statistics_meta table.

SELECT *
FROM "statistics"
Where metadata_id IN (37,41)
Order by id desc

The sum of 247 is the total amount of compensation from the first day that energy dashboard started recording.

The sum of 717 is the total amount of cost from the first day that energy dashboard started recording.

1 Like

Nothing for 47. But a phone that needs to be charged soon

I guess I might have to try that.

I’m using MariaDB with MySQL workbench for a client
data returned from query.
ID 115 is for export and ID 105 for import as seen below


image

Yep, so obviously $7 an hour for electricity cost is a bit silly right?

Yes, Yes it is. But I’m not sure what this shows other than it’s calculating incorrectly.
Is the inference that it’s a setting of a sensor and not a display issue?

It shows that the statistics engine is recording a cost difference of say $7 per hour based on the acumulated difference of the grid import energy cost sensor over the hour. If you go to the actual sensor for that same time period and don’t see a $7 increase, then there is something causing statistics engine to misread or miscalculate the difference it is seeing from that specific sensor.

We have established that the energy amount is accurate, and that it’s just the cost (multiplier) that is not accurate in energy dashboard.

As I said, I have no experience with using input_number so I cannot rule out the presence of this number type and the settings below having a good or bad effect when used as a multiplier. Given you now have automation updating this value for you, there shouldn’t be a need for you to manually update this value from the gui, so why hang onto it? Just trying to help narrow down potential causes

image

That’s a great question.
This helper established the Entity that the automation updates.
It was working great up until the 2022.8 upgrade.

If your sums for the cost and compensation are at $14k and $33k, then it’s safe to say this cost data is unreliable.

You could even go back through the statistics and see where it all went wrong and wether these specific metadata_id ever worked properly

I can sort of see the issue here

Let’s focus on this block


f

On the left is dollars , in the middle is thousands of dollars.
If you are adding $4 to $32795, the next sum should be $32799.

There’s nothing wrong with using an input number.

Yeah, fair enough. Just clutching at straws

1 Like

Even though you have a 1:1 feed in tariff, Have you tried having a seperate price sensor for grid import and another price sensors for grid export?

It seems the fault started here and the costs just keep incrementing with the previous cost from there until a random reset ( which could have been me forcing it.)