HomeWizard and 2023.12

Hi,

In 2023.12 things changed: https://github.com/home-assistant/core/pull/104493
Unfortunately I had to change my sensor in the Energy Dashboard, but now I’ve lost my history:

The one on top is the old sensor, which isn’t updated anymore. The 3rd is the new one, starting from zero.

Is there a way I can migrate my old statistics to the new one? Now I’ve lost a year of data.

Can you open an issue for this on GitHub?

Open Issue

@pbootsma how did you swap the id’s? looking for an easy way.

Big problem with HomeWizard. The upgrade disabled the t1 import entities and generated a new entity without history. So I was missing complete history. Swapping statistics id’s in de database resolved this. But utility meters based on the T1 entities also broken. Cost me already 3 hours to correct things in the database and statistics. Had to correct 17 devices…

What I noticed is that it generated dutch names i.s.o. english ones. And based on the device name. So maybe language setting related? For some devices which have been renamed in the passed I have half the entities with the previous name, half the new name, half in english and half in dutch. A mess!

My solution in the database, example for the wasmachine:

Get the ids:

select * from  "statistics_meta" where statistic_id like "%was%import%"

Result:

435	sensor.wasmachine_total_power_import_t1
1196	sensor.wasmachine_totale_energie_import

3 sql commands to swap the ids

update  "statistics_meta" set statistic_id="sensor.wasmachine_total_power_import_t1_old" where id = 1196
update  "statistics_meta" set statistic_id="sensor.wasmachine_totale_energie_import" where id = 435
update  "statistics_meta" set statistic_id="sensor.wasmachine_total_power_import_t1" where id = 1196

I did the same for states meta:

SELECT * FROM "states_meta" where entity_id like "%was%import%"

Result:

252	sensor.wasmachine_total_power_import_t1
4592	sensor.wasmachine_totale_energie_import

3 sql commands to swap the ids

update "states_meta" set entity_id="sensor.wasmachine_totale_energie_import_old" where metadata_id = 4592
update "states_meta" set entity_id="sensor.wasmachine_totale_energie_import" where metadata_id = 252
update "states_meta" set entity_id="sensor.wasmachine_total_power_import_t1" where metadata_id = 4592

Oh, and restart Home Assistant afterwards. It caches the ids…

2 Likes

Yep, was the same way I wanted to do it and fixed now :-).

Done creating the issue.

Thanks for the solution!

A breaking change just for "cleanup’, good one. Lost 14 months of history :slight_smile:

1 Like

Good to read that someone found a solution. I found the codes. Where can I give the commands? I’m using MariaDB10 on a synology nas.

Found it, it was on a tab called SQL.

Thanks for the solution!

1 Like

Hi @Frank_Howell and @pbootsma I don’t mean to derail your thread, but I’m asking for your help, I seem to have encountered a strange issue related to my HomeWizard SDM230 entity statistics, and I’m not sure how to resolve it exactly, but I think I’m getting closer.

I get that there is no obligation for anything, I’m just asking for help if anyone has time.

I opened a thread here to try explain the issue: