Noobie: Need to Correct Compensation Payments Under "Electricity" Tab on Energy Dashboard

Hi,

Relative Noobie to HA but have some (quite old) experience with SQL & RDBMSs!

So, in antricipation of getting some CT Clamps on most devices in my home, along with buying an old Emporia Vue, I set up my Energy Dashboard the other day.

For some background, I have a (small) Solar Array, a Powerwall 3 and a Zappi EV charger. Zappi is wired in upstream of the PW3. Grid is via a Smart Meter with Octopus as my supplier. From Octopus I have a “Mini” IHD, which, along with the PW3 and Zappi, I think I have integrated into HA OK. HA is up to date with all revisions and patches applied to date.

I set up my Energy Dashboard config a few days ago, but neglected to assign the relevant sensor to the “compensation rate” for export. It took me several days to notice (!), but eventually realised that I was not getting any financials out of HA for my Solar exports.

After a short bit of investigation my omission was revealed. I assigned “sensor.octopus_energy_electricity_<meter number>_export_current_rate” (where “<meter number>” is my meter number) to the “export rate compenstation” field under “Configure grid connection”.

And the export financials started appearing for the remainder of that day and subsequently. However, I was also expecting these finacials to be applied retrospectively as well - they were not!

For a couple of days I have been going round and round in circles with the Google AI, trying to resolve this issue. It (the AI) has written SQL scripts galore for me to apply and modify the statistics, statistics_short_term, and/or the statistics_runs tables, Its also had me trying to insert values into the states table. Nothing worked and we just kept going round the same old loops. In the end, I gave up with the AI, as it clearly did not know what it was doing; and, in reponse, it recommended posting here for some “human input”. I was wondering if anyone could help point me in the correct direction here. I just want to set the export compensation values for a few days, so that my data is not comprised from Day #1.

Many thanks for any info anyone can provide.

Regards,
Harry.

If you have a CSV, TSV, or JSON file with the data, you can use import statistics to bring the previous data into the sensor. I’m not too familiar with this custom component, but I’ve seen good feedback about it.

Ah yes, many thanks - installing “import statistics” has got me a good bit further on (I think!) I’ve managed to use it to export what stats HA has for the sensor “sensor.grid_export_daily_total_from_octopus_mini_compensation” Its missing the few days from when I created the Energy Dashboard to when I realised that that I hadnt set this sensor up as the “Export Compensation” feed in its configuration. OK, all I need to do (I think) is augment this file and then re-import it using the “import statistics” tool? HOWEVER - there are three columns that perplex me a bit: sum, state and delta. I’m guessing that “sum” contains the rolling total to date (increases in perpetuity?), and “delta” is the change since the last row? However, in that case, what is “state” for? Any ideas?

State is typically the status that a sensor shows normally. All other data will be attributes of the sensor. You can see what attributes a sensor has by clicking it, a pop-up window appears that shows the state and, underneath, the history. Click the 3-dot icon in the top right, then click details. The details will show ALL the data for the sensor, including the GUI state, raw state, and all attributes.

If any of the attributes are useful data that you want to use, maybe for scripts and automations, you can create template sensors that will take an attribute from one sensor to show as the state of a template sensor. Don’t want to get ahead of myself, let alone yourself, so I’ll pause here. But, yea, lots you can do lol

Hi - thanks for that. In the meantime, with the help of the Google AI,I worked out what the state was in my particular case. So, just to let you know (and to help others in the future), Solution is to first export the inventory, detailing all the sensors that stats are maintained for. Then find the relevant sensor. (In my case this was “sensor.grid_export_daily_total_from_octopus_mini_compensation”. Then export this sensor’s stats. There are 3 relevant columns output: “state”, “delta” & “sum”. “delta” is the amount relevant for that hour. This is what I then found out: In the case of my “increasing daily total” sensor, “state” is the culmulative total for that day. This resets to zero on every “midnight row”. Finally, there’s the “sum” column: this is a culmulative total that NEVER resets. It must always be increasing (or static in the case of a 0 delta) from one row to the next. Excel is your friend here. What I did was to use formulas for the “state” & “sum” columns and then just plugged in the deltas as numeric values. If, like me, you didn’t know how the daily total broke down between the hours, I just lumped the entire daily delta into the 23:00 row for each day. The only “gotcha” when importing this back into the HA database, using the “import statistics” action (which comes from installing the “import statistics” HACS package), is that it will NOT allow you to import the “delta” column at the same time as the “sum” and “state” columns. This was not a problem: I just converted my “sum” and “state” columns from formulas to values and then deleted the “delta” column. I then saved it as a CSV (making sure to preserve the same date-time format as the CSV was exported with) and then imported these new stats using the above-mentioned import stats action. From my checks of the Energy Dashboard afterwards, if definately solved my problem!