Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
User avatar
andrehj
Posts: 51
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by andrehj »

Somehow a device with a lot of historic data is no longer present in Domoticz (also in Setup → Devices) :( . Don't understand how that happened, I must have deleted it accidentally... :oops:

From the output of scripts I can see that it's missing since the 8th of June.
I have a domoticz_backup.db from June 2nd.

Is it possible to retrieve the device data (table) from that old backup and somehow insert it into my current database? Is there a how-to which explains how to do that? From my scripts I know the correct Device Idx.

From other devices and scripts I can estimate the values of the missing days. It would be nice if I could insert these into the table as well. But how do I accomplish that?

Thanks in advance for any help,

Andrehj
Last edited by andrehj on Friday 04 July 2025 10:47, edited 1 time in total.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by waltervl »

See the database merge tool mentioned in this topic: viewtopic.php?p=312243#p312243
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Varazir
Posts: 432
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by Varazir »

waltervl wrote: Thursday 03 July 2025 15:55 See the database merge tool mentioned in this topic: viewtopic.php?p=312243#p312243
I can't download the file

https://releases.domoticz.com/releases/ ... BMerger.7z
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
jvdz
Posts: 2330
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by jvdz »

New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
Varazir
Posts: 432
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by Varazir »

jvdz wrote: Thursday 03 July 2025 20:09 Try: https://releases.domoticz.com/release/t ... BMerger.7z
Thanks it worked, It looked strange at first but didn't try to remove the extra.
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
andrehj
Posts: 51
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by andrehj »

waltervl wrote: Thursday 03 July 2025 15:55 See the database merge tool mentioned in this topic: viewtopic.php?p=312243#p312243
Thanks for the help!

However, as far as I understand, that tool can only merge some specific tables, or all tables. I just need to gather my historic data from one specific Idx, and integrate that into the current database.
I don't understand how I can do that with this tool.

Do I have to simply run
DomoticzDBMerger.exe --inputdb=olddatabase.db --outputdb=currentdatabase.db --merge-all
and hope that it works?

Or can I use the command
--transfer-old=idx --transfer-new=idx
to copy one idx from the old db to the current db? And than by keeping the idx the same it should just copy that index?
DomoticzDBMerger.exe --inputdb=olddatabase.db --outputdb=currentdatabase.db --transfer-old=137 --transfer-new=137

And will the latter work if a device with the new index is not yet present in the output database? Or do I have to create it first and let the merger simply fill that data?

So many questions...

Too bad there is no more elaborate help for this tool.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by waltervl »

If you know the device type of the device that misses data you can determine what the table is you need to merge.
Is the device completely gone or just some historic data?
Because when the device is completely gone you have a bigger issue.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
andrehj
Posts: 51
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by andrehj »

waltervl wrote: Friday 04 July 2025 12:27 If you know the device type of the device that misses data you can determine what the table is you need to merge.
Is the device completely gone or just some historic data?
Because when the device is completely gone you have a bigger issue.
The device is completely gone.

Idea: Create a new device (of the same type), and than add the data from the table of the old database?
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by waltervl »

That could be the right direction to create a new similar device and the use the command option
--transfer-old=idx --transfer-new=idx

Was it already a dummy device in the past or related to a normal hardware gateway? Because when connected to an existing hardware gateway it could automatically be recreated after a restart of Domoticz or the hardware gateway.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
andrehj
Posts: 51
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by andrehj »

Sorry, should have mentioned that. It was a dummy device in which I track the energy consumption of my heatpump. It gets its data once a minute from a script that reads the values from an ABB energy meter via Modbus.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by waltervl »

Then create a new dummy device and do the transfer/merge.
Make a backup before you start the transfer/merge!!!!
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
andrehj
Posts: 51
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by andrehj »

No luck after an hour or so of trying.
Starting Domoticz with the backup of June 2 shows this device:
2025-07-04 olddevice.png
2025-07-04 olddevice.png (6.08 KiB) Viewed 80 times
So I created a new device of the same type:
2025-07-04 newdevice.png
2025-07-04 newdevice.png (9.96 KiB) Viewed 80 times
However, when I run the command:
DomoticzRestore\Werk>DomoticzDBMerger.exe --inputdb=domoticz_backup2-6.db --outputdb=domoticz.db --transfer-old=137 --transfer-new=504

I get the output:
Both specified devices should be of the same type !

But of course they are... :( The only difference I see is that the new device somehow has a signal strength indicator, but I cannot imagine that that is the issue...
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by waltervl »

Another option now is to use "DB Browser for SQLite". it can be downloaded from sqlitebrowser.org.
You can export the device history data from the backup database to excel, modify the idx and import it into the current database (stop domoticz first!). The data is in the table Calendar_Meter.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
andrehj
Posts: 51
Joined: Sunday 06 January 2019 14:26
Target OS: -
Domoticz version:
Contact:

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Post by andrehj »

Thanks, but I already gave up on this device in Domoticz. Maybe after my holiday I will fiddle with the SQL tool.
Just made a new device "Electric instant + Counter", for both the power en energy data of the heat pump.
Luckily I have an export of the daily counters to Excel (never trust one single database!), so most of my data is still retained, only one month is missing.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest