Cleanup unused devices Topic is solved

Moderator: leecollings

Post Reply
peter8wun
Posts: 3
Joined: Monday 25 July 2016 14:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Cleanup unused devices

Post by peter8wun »

Hi,

My domoticz installation received quit a large number of divices from my RFlink hardware (>3000) that are not mine and I think this makes my domotics slow. For instance when accessing the list of divices.

is there a problem executing "delete from DeviceStatus where used =0" on the database to get rit of these devices?

Peter
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Cleanup unused devices

Post by manjh »

peter8wun wrote: Monday 09 March 2020 15:04 Hi,

My domoticz installation received quit a large number of divices from my RFlink hardware (>3000) that are not mine and I think this makes my domotics slow. For instance when accessing the list of divices.

is there a problem executing "delete from DeviceStatus where used =0" on the database to get rit of these devices?

Peter
In the list of devices, click on "not used devices" at the left top. After this, select "all" for "show entries.
This will give you a complete list. Now select the little selectbox right next to the garbage bin, then click the garbage bin itself.
This gets rid of all unused devices.
Hans
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Cleanup unused devices

Post by waaren »

peter8wun wrote: Monday 09 March 2020 15:04 My domoticz installation received quit a large number of divices from my RFlink hardware (>3000) that are not mine and I think this makes my domotics slow. For instance when accessing the list of devices.

Is there a problem executing "delete from DeviceStatus where used =0" on the database to get rit of these devices?
Not really but
  • to be safe make sure you have a backup and only do this when domoticz is not active.
  • If you have the allow new hardware set to yes they will come back.
  • These devices will also have data in other tables.
You can identify the tables (potentally) with data from these devices

Code: Select all

select name as Tables_containing_deviceRowid from sqlite_master where type='table' and sql like '%devicerowid%';
to delete records with devicerowid's from unused devices from these tables

Code: Select all

delete from LightingLog where devicerowid in (select id from devicestatus where used = 0);
delete from Rain  where devicerowid in (select id from devicestatus where used = 0);
delete from Rain_Calendar where devicerowid in (select id from devicestatus where used = 0);
delete from Temperature where devicerowid in (select id from devicestatus where used = 0);
delete from Temperature_Calendar where devicerowid in (select id from devicestatus where used = 0);
delete from Timers where devicerowid in (select id from devicestatus where used = 0);
delete from SetpointTimers where devicerowid in (select id from devicestatus where used = 0);
delete from UV where devicerowid in (select id from devicestatus where used = 0);
delete from UV_Calendar where devicerowid in (select id from devicestatus where used = 0);
delete from Wind where devicerowid in (select id from devicestatus where used = 0);
delete from Wind_Calendar where devicerowid in (select id from devicestatus where used = 0);
delete from Meter where devicerowid in (select id from devicestatus where used = 0);
delete from Meter_Calendar where devicerowid in (select id from devicestatus where used = 0);
delete from MultiMeter where devicerowid in (select id from devicestatus where used = 0); 
delete from MultiMeter_Calendar where devicerowid in (select id from devicestatus where used = 0);
delete from Notifications where devicerowid in (select id from devicestatus where used = 0);
delete from LightSubDevices where devicerowid in (select id from devicestatus where used = 0);
delete from DeviceToPlansMap where devicerowid in (select id from devicestatus where used = 0);
delete from SceneDevices where devicerowid in (select id from devicestatus where used = 0);
delete from SharedDevices where devicerowid in (select id from devicestatus where used = 0);
delete from Percentage where devicerowid in (select id from devicestatus where used = 0);
delete from Percentage_Calendar where devicerowid in (select id from devicestatus where used = 0);
delete from Fan where devicerowid in (select id from devicestatus where used = 0);
delete from Fan_Calendar where devicerowid in (select id from devicestatus where used = 0);
delete from Pushlink where devicerowid in (select id from devicestatus where used = 0);
and lastly

Code: Select all

delete from devicestatus where used = 0;
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
peter8wun
Posts: 3
Joined: Monday 25 July 2016 14:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Cleanup unused devices

Post by peter8wun »

Thanks for the quick and complete answer. this helps tremendously.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Cleanup unused devices

Post by waaren »

manjh wrote: Monday 09 March 2020 15:56 In the list of devices, click on "not used devices" at the left top. After this, select "all" for "show entries.
This will give you a complete list. Now select the little selectbox right next to the garbage bin, then click the garbage bin itself.
This gets rid of all unused devices.
Not sure when the fix was applied but on older versions this approach (which should be the preferred one) caused domoticz to 'hang' when > 5 devices where selected for deletion.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest