i found a new way that works great now and did not even mess up my cost device @fversteegen
You right they did do something so this is what i did after the old method did not work anymore.
What do you need:
Heidi sql (sql manager)
MariaDB or proxmox LXC Tteck scripts (AWSOME GUY!!!)
Home Assistant
Adminer (its ike phpmyadmin) i prefer this
or
Phpmyadmin
The set-up:
- ssh into homeassistant and duplicated the .DB called homeassistant_v2.db.
- Created a new database with HEIDI with
Just open HEIDI and login to your mysql and create the DB
utf8mb4_general_ci and name homeassistant this is the database we gonna use later, now let homeassistant
Now we need to change something in the homeassistant.yaml
To do that just go into your homeassistant.yaml and be sure the line of recorder looks like this, ofcourse don’t forget to replace the ip username and password.
recorder:
db_url: mysql://USERNAME:PASSWORD@YOURIP/homeassistant?charset=utf8mb4
After you done this, save and restart homeassistant and let it run for 5 minutes and shut it down.
or if you dont want to shut it down just change the recorder back that it uses the old default database file again.
-
open heidi and select the database named homeassistant and empty all rows/tables and delete all keys from all tables (not the orange ones!) using (heidi sql)
just hover over the key and press remove
-
created a new database called (homeassistant_test) the old dump database
-
now we start using the script again to dump the same homeassistant.db we backed up before again into the new created database. homeassistant_test) c6de-
sqlite3mysql
–sqlite-file /config/home-assistant_v2.db
–mysql-database homeassistant
–mysql-host core-mariadb
–mysql-user homeassistant_test
–mysql-password ‘YOURPASSWORD’
–ignore-duplicate-keys
-
go to homeassistant_test database and check the data of homeassistant_test and look for the table statistics_short_term and open it, copy the (CREATED) row (im using heidi sql)
-
than open statistics_short_term in the database named homeassistant and paste the row
it does not matter where
-
compare the rows from homeassistant_test with homeassistant and
be sure in (events | recorder_runs | states,statistics )have the colum (created) if not just copy them over, (use the corresponding column from the other database)
-
also check if there are missing columns in homeassistant u can copy them to from homeassistant_test
-
now finally we run the script again and once more we use the homeassistant.db we created in the beginning and this time we gonna dump it in the database named homeassistant thats the one we edited and made it ready and compatible with mariadb.
sqlite3mysql
–sqlite-file /config/home-assistant_v2.db
–mysql-database homeassistant
–mysql-host core-mariadb
–mysql-user homeassistant
–mysql-password ‘YOURPASSWORD’
–ignore-duplicate-keys
if everything went ok and you open the DB u see that FLOAT changed to DOUBLE
see here my old homeassistant_test
new dumped homeassistant
Go in to the homeassistant YAML file and add it to the recorder and start HASS and BOOM it works.
I did a mix of everyone but none of that data went corrupted or lost during this migration, atleast not for me.
Also a big plus is that the COST entity won’t get messed up at all
So whoever wants to try this always make a BACKUP!
Thanks to @eddiewebb @spitf1r3 @SirACEair @Alex_Pupkin for theyr info and scripts so i could make a tutorial.
I tested this on my local server and proxmox HASS server, working great.
My Mariadb LXC is installed on Proxmox
Tteck scripts (AWSOME GUY!!!)