My point is about naming convention. In Domoticz the (device) ID has a specific meaning. The idx has another meaning.
I think it is good practice to have just one name for one attribute, and not one name (ID) that can mean two different things (device-ID OR device-idx).
At least you should update your documentation. Now you use terms like 'device.id' or 'mydevice.id' where you mean idx.
The problem is that I cannot change this without breaking many people's scripts.
I don't think so, it won't be a problem. First of all, dzVents has just recently been added to Domoticz, so it is better to correct it now than wait longer. But, more important, changing the attribute-name from 'ID' to 'idx' does not influence 99% of the scripts. In the trigger, the key-word 'ID' or 'idx' are not used, just the number.
Ofcourse it is not my business. Perhaps the Domoticz developers should look at this and give their opinion about one name for two different things in their program.
Don't be afraid to take the right decision
- - - -
So, what is Unit exactly?
Some devices can switch two or more receivers. The unit-number is a kind of sub-number for the device.
A wall switch with two buttons has one ID and two unit-numbers.
A remote can switch three or even 16 devices. So, there are three or 16 unit-numbers.
For GPIO-switches, the unit-number identifies the gpio-pin.
Etc.
- - - -
What I can do is add the idx attribute (which will have the same value) and add deviceId. I will also add the possibility to get a device by either id(x) or deviceId.
That could be the second-best option.
deviceId + Unit is not unique. I have several devices that have the same deviceID + Unit. In fact, the idx is more unique than this combination.
For a switch (or transmitter) the (device)ID and Unit are the unique Identifier. That is independent of your Domoticz instance. In Domoticz, the idx is the Unique Identifier. If you delete and re-add a device, the ID and Unit will be the same, but the idx will change.
If you use a master-slave Domoticz, you will indeed see some ID's and Units twice (or more). The 'hardware' column indicates where the device comes from. Practically, the three columns 'hardware', 'ID' and 'Unit' together make the Unique Identifier of each device. But I don't think Domoticz has a check on this.
You can even use deviceId as the on-trigger.
I suppose not. You would also need the Unit and even the hardware-name.
- - - -
So for now I just add the deviceId and unit attributes to all devices and you can use the collection iterators to filter/search for devices with that deviceId/unit if they turn out to be unique for you.
I am happy with that. Thank you.
But... don't forget to update the documentation and write idx where you mean idx.