Page 1 of 2

Cleaning IDX

Posted: Wednesday 10 February 2016 17:08
by ricorico94
Hi,

Is it possible to "clean" the various IDX ?

I recently began my Domoticz and I have installed several times some devices, or I installed similar devices after having installed other types of devices in meantime.
For instance, I always had to make several attempts to add zwave devices (I think I had not udnerstood properly the actions to take between the push on dongle and then addition through menu of Domoticz..), so I have plenty of IDX which are unused since I deleted the "failed attempts".
Or I also included some switches for blinds for testing, then included some virtual switches for other purpose (like adding timers for heaters), then added again some other switches for blinds. As a result, I have consecutive IDX for blinds at 22, 23, 24, and then the remaining ones at 34 and 37.
Is there anyway to clean the IDX by reallocating the various IDX to new ones to have kind of logic with ranges per category ? Something like: 1-10 : for blinds; 11-20 for heaters; 21-50 for virtual switches; etc. ? I ould avoid also reaching "high numbers" for IDX while having only a few dozens of IDX really active.
(of course, cleaning would mean also updating all external scripts, calls, etc. A pain, but why not)

br,
ricorico94

Re: Cleaning IDX

Posted: Wednesday 10 February 2016 18:41
by gizmocuz
No, you can delete sensors from the devices table, the idx values are just indexes, and do not need to be in order

Re: Cleaning IDX

Posted: Thursday 11 February 2016 10:40
by ricorico94
Hi ,
Too bad we can't organise those indexes later on.
It's like IP subnetworks.. it can work with IP addresses here and there, but it looks nicer when it's ordered. I understand these numbers are database indexes (primary key, maybe ?), but it would ease readibility if we could organise them by categories: for instance, when writing scripts, having IDX organised with a "logic" behind could be interesting.

br,
ricorico94

Re: Cleaning IDX

Posted: Thursday 11 February 2016 11:04
by RobertH
Is it in some way possible to see wich IDX belong to for example a Fibaro dimmer?
Because sometimes you add more than one new z wave unit and over a little time they add some extra devices.

Re: Cleaning IDX

Posted: Thursday 11 February 2016 15:17
by gizmocuz
These are database indexes and should not be changed
yes, goto the devices overview, and sometimes adding new devices should not happen, after a good include it should be stable

Re: Cleaning IDX

Posted: Thursday 11 February 2016 17:57
by nayr
I just broke into the 200's IDX, im sure Gizmocuz here likely has device id's in the 4 digits..

If your that OCD about it wipe everything out and start over, but there really is no problem.. who cares what number that is, the requirement is that it be unique and static.. not in order, or small or big or anything else an unhealthy mind will consider important.

implementing your request breaks one of the requirements.. that it remain static.

Re: Cleaning IDX

Posted: Thursday 11 February 2016 18:01
by gizmocuz
The only reason why the IDX value is visible to end-users is for people that use it with scripts/lua
If you dont use that, ignore it

yep... 4 digits (2924)

Re: Cleaning IDX

Posted: Friday 19 February 2016 18:59
by stlaha2007
If youre despirate in reordering, i would suggest replicate your devices by creating new devices with the json api. Then you are able to assign your logical device type related numbering.

But keep it simple. Namingschemas are easier to understand then manualy rebuilding your device numbering ;-)

And dont forget that the last number youve used 'manualy' will be followed by a next number when domoticz finds a new devices.

Grtz,
Stephan

Re: Cleaning IDX

Posted: Friday 19 February 2016 19:01
by gizmocuz
it is just a number.... :?:

Re: Cleaning IDX

Posted: Friday 19 February 2016 21:27
by nayr
gizmocuz wrote:it is just a number.... :?:
How dare you say that to someone with OCD!? :lol:

they are tormented by stuff like this. ;)

Re: Cleaning IDX

Posted: Saturday 20 February 2016 19:00
by stlaha2007
Nayr / Gizmocuz... Please :-)) . I like ("my") order to...

Someone asked for renumbering idx.


Grtz,
Stephan

Re: Cleaning IDX

Posted: Saturday 20 February 2016 22:28
by NietGiftig
stlaha2007 wrote: Someone asked for renumbering idx.
It would be silly to do.
Its an intern database number

Anything else is more important to do then altering database ID's just because it is not in the order you like. ;)

The people here are trying to create an new stable release, much, I say much more important then not relevant optics.

Re: RE: Re: Cleaning IDX

Posted: Saturday 20 February 2016 22:34
by stlaha2007
NietGiftig wrote:
stlaha2007 wrote: Someone asked for renumbering idx.
It would be silly to do.
Its an intern database number

The people here are trying to create an new stable release, much, I say much more important then not relevant optics.
Totally agree
Waiting for the new stable with selector switches etcetera....

But again. Someone (Topic Starter) asked for it, which is not ME.

Grtz,
Stephan

Re: RE: Re: Cleaning IDX

Posted: Saturday 20 February 2016 22:40
by NietGiftig
stlaha2007 wrote: But again. Someone (Topic Starter) asked for it, which is not ME.
Yes that's correct and an answer was given
http://www.domoticz.com/forum/viewtopic ... 859#p74589

Re: RE: Re: Cleaning IDX

Posted: Sunday 21 February 2016 0:38
by raym
nayr wrote:I just broke into the 200's IDX, im sure Gizmocuz here likely has device id's in the 4 digits..

If your that OCD about it wipe everything out and start over, but there really is no problem.. who cares what number that is, the requirement is that it be unique and static.. not in order, or small or big or anything else an unhealthy mind will consider important.

implementing your request breaks one of the requirements.. that it remain static.
I presume the limit on DZ device indexes is high but what happens with Z-Wave node IDs? Once the 232 node limit is reached, does DZ/OZW start cycling through the IDs that may not have been used? I suspect I'll never reach such limits... Just curious.

Re: Cleaning IDX

Posted: Sunday 21 February 2016 8:02
by Egregius
The device IDX aren't anything to worry about. You are not getting to 9223372036854775807 very quickly.
And then, if it's the autonumbering of SQLite3 that is used there's no problem:
Longer answer: If you declare a column of a table to be INTEGER PRIMARY KEY, then whenever you insert a NULL into that column of the table, the NULL is automatically converted into an integer which is one greater than the largest value of that column over all other rows in the table, or 1 if the table is empty. Or, if the largest existing integer key 9223372036854775807 is in use then an unused key value is chosen at random.
The Zwave IDX on the other hand, I'm now at 89 and also curious what happens when the limit is there...

Re: RE: Re: Cleaning IDX

Posted: Sunday 21 February 2016 8:52
by stlaha2007
Egregius wrote:The device IDX aren't anything to worry about. You are not getting to 9223372036854775807 very quickly.
And then, if it's the autonumbering of SQLite3 that is used there's no problem:
Longer answer: If you declare a column of a table to be INTEGER PRIMARY KEY, then whenever you insert a NULL into that column of the table, the NULL is automatically converted into an integer which is one greater than the largest value of that column over all other rows in the table, or 1 if the table is empty. Or, if the largest existing integer key 9223372036854775807 is in use then an unused key value is chosen at random.
The Zwave IDX on the other hand, I'm now at 89 and also curious what happens when the limit is there...
A quick google let to some maintenance questions about the effects of reindex and vacuum.

Depends on what maintenance procedures are implemented in such case.

I think the one developing Domoticz and its database, Gizmocus??, can give some info about this. Im curious too, however i dont expect there would be a problem as there are protocols that are limited earlier then the database limits.


Grtz,
Stephan

Re: Cleaning IDX

Posted: Sunday 21 February 2016 9:01
by gizmocuz
ZWave, the limit will be 254 nodes
SQLite, when you backup your database in domoticz from the settings page, there is an automatic vacuum done
If you renumber the indexes, then all is lost, like the temperature tables references id's from the device table and so on

Re: Cleaning IDX

Posted: Sunday 21 February 2016 9:48
by stlaha2007
Big thanks.

But is the vacuum done before on 'live' db or only into backup?

Grtz,
Stephan

Re: Cleaning IDX

Posted: Sunday 21 February 2016 9:48
by gizmocuz
Only when a backup is made, before the backup is made, the backup is vacuumed