Open tomatensaus opened 1 month ago
Install the "SqlLite Web plugin" in home assistant and run this query
SELECT * FROM "statistics_meta" where statistic_id like "%total_grid_import%"
It will give you output
id | statistic_id | source | unit_of_measurement | has_mean | has_sum | name |
---|---|---|---|---|---|---|
13 | sensor.deyeinvertermaster_summary_total_grid_importbuy | recorder | MWh | 0 | 1 | |
82 | sensor.deyeinvertermaster_summary_total_grid_importbuy_cost | recorder | ZAR | 0 | 1 | |
104 | sensor.deyeinvertermaster_summary_total_grid_import_buy | recorder | MWh | 0 | 1 |
Note that we have ID=13 (the old entity name) that need to be pointed to ID=104 (the new entity name) This is achieved with
UPDATE statistics SET metadata_id = 104 WHERE metadata_id = 13;
You can also just look at the data that will be changed
SELECT * FROM statistics WHERE metadata_id = 13 LIMIT 100;
if it complains about "UNIQUE constraint failed: statistics.metadata_id, statistics.start_ts" then you likely have a row with a date that is the same for both entities, you can find the duplicates with:
SELECT metadata_id, id, start_ts, COUNT(*)
FROM statistics
WHERE metadata_id IN (13, 104)
GROUP BY start_ts
HAVING COUNT(*) > 1;
metadata_id | id | start_ts | COUNT(* |
---|---|---|---|
13 | 332545 | 1713862800.0 | 2 |
Look for the ID of the duplicate entry (eg 332545) and remove with
DELETE FROM statistics WHERE id = 332545;
sensor.deyeinvertermaster_summary_total_grid_importbuy is renamed to sensor.deyeinvertermaster_summary_total_grid_import_buy
Similarly with exportsell and export_sell
This causes all my graphs to stop displaying