Page 1 of 1

Energy meter replacement with retention of historical data

Posted: Wednesday 05 January 2022 8:14
by JanCeuleers
I am in the process of preparing an upgrade of my electrical installation from single phase to 3-phase supply. I currently have an Aotec energy meter in use, and will have to replace it with the 3-phase model. I would like to do so without losing the historical data I have accumulated. How do I do that?

As a matter of fact the situation is slightly more complex than described above. In fact I have two single-phase energy meters in use at the moment: one that measures grid energy and another that measures solar energy. I have created a dummy energy meter as well, and a LUA script calculates energy consumption as the difference between the two measured values. Since the solar inverter is and will remain single-phase, I will also continue using that energy meter.

So I guess that I have two goals:

1. replace the grid energy meter such that the historical readings of the single-phase meter become associated with the 3-phase meter;
2. modify the LUA script such that the energy consumption is calculated from the new 3-phase grid energy meter reading less the existing single-phase solar energy meter.

Any hints would be gratefully received.

Re: Energy meter replacement with retention of historical data

Posted: Wednesday 05 January 2022 8:35
by azonneveld
I think the only solution is to modify the db manually.
A good tool to do so is: SQLiteStudio

You need to copy your data from the old meter to a new table, then modify the hardware id's in the new table, then insert into existing table.
Take some copies of your database and use a domoticz test application on your desktop or test rpi, and apply on that setup.

Re: Energy meter replacement with retention of historical data

Posted: Wednesday 05 January 2022 17:31
by JuanUil
so a small howto:
in Domoticz go to settings tab backup/restore
- backup your dbase
- open it in sqlite
- open the older dbase also in sqlite
- export the desired table of the latest dbase to csv
- copy the new data from the older database
- paste them in the csv
- save it
- delete the table in the latest dbase
- import the csv file in the latest dbase
- restore the newest dbase in domoticz

Maybe a point of attention:
Don't delete the header data
Sometimes the csv file has a format for the date as 03-02-2020
Most time the dateformat in the dbase is as 2020-03-02
So change the format in the csv accordanly to the format in your database.

finished! :D

succes!!
Jan

Re: Energy meter replacement with retention of historical data

Posted: Monday 24 March 2025 18:52
by monkee
The data for the new meter will have a new, lower value of the 'Counter' field: It will normally start at 0 with a new meter. The (electricity) meter supplies both actual power (Watt) and energy (kWh). How is this handled? I tried it and the month where the Counter drops to a lower value is missing from the yearly graph. All other months, including the ones with the old, higher Counter values are shown correctly.
I understand that for showing daily and weekly energy consumption the Values (Watt) are used (per 5-minute intervals and summed). For the monthly data the Counter values (kWh) are used (by subtraction)?