Supposing you have a kWh device, in Domoticz, that you want to replace with a new one (the old device is broken, for example). To import all data from the old device into the new one, you have to:

  1. select the old device (click on Edit button)
  2. click on Replace button and select the name of the new device

In this way, Domoticz transfers all history from the old device to the new one.

If for some reason this procedure did not work, you can do in this way (this is the procedure for Linux/unix):

  1. keep note of the idx for the old device: click on Edit button for the old device and write down its idx value (called OLD_DEVICE_IDX, later)
  2. write down the idx of the new device (called NEW_DEVICE_IDX, later)
  3. open the domoticz database: from the terminal/shell, enter the domoticz directory and type the command
    sqlite3 domoticz.db
  4. check calendar data from the old device, writing the query
    select * from Meter_Calendar where idx=OLD_DEVICE_IDX
  5. in case the device is not a meter, but a rain , percentage or other type of device, use the command
    .tables
    to find out the name of the database table that contains data for that device, and write the same query as point #4 selecting the right table name (replacing Meter_Calendar with Rain_Calendar, Percentage_Calendar, Temperature_Calendar, ...)
  6. Now change the idx for the historic data to the new device idx, using the query
    update Meter_Calendar set DeviceRowID=NEW_DEVICE_IDX where idx=OLD_DEVICE_IDX
    Specify the right table name, if device is not a meter.
  7. .quit to exit sqlite3 program.

In this way the historic data of the old device has been set to the new device.