The Vera Community forums have moved!

General => General => Topic started by: jlind on August 23, 2017, 09:37:15 am

Title: Change Device ID
Post by: jlind on August 23, 2017, 09:37:15 am
Hi,
This is an odd question I know, but is it possible to change the device ID for a device on my Vera?  I actually want to lower the device ID to a value that no longer currently exists on my Vera.

Unfortunately, my Vera interfaces with another software, that I didn't write, that only allows device ID's up to 255.  I'm unsure of how long it will take to fix the other software so I was curious about a possible workaround.

Thanks!

Title: Re: Change Device ID
Post by: RichardTSchaefer on August 25, 2017, 07:04:22 pm
The only way to do this is to:
1) Backup  your Vera in case you hose it!
2) Shutdown the LuaUPnP process.
3) Decompress the user_data.json.lzo
4) Edit user_data.json
5) Compress user_data.json
6) Power Cycle your Vera.
7) You may have to fix any scenes and or PLEG devices that reference this device.

All of these steps past step 1, require considerable Unix knowledge, and an understanding of json syntax. I will not provide any more details. If you hose the user_data.json file, you can brick your controller.
 
Title: Re: Change Device ID
Post by: bogdanf on August 26, 2017, 08:30:48 pm
You can use the following code in the 'Test Luup Code' section (Apps - Develop Apps):

luup.attr_set("id","desired_id",current_id)

Replace the desired_id with the new ID and current_id with the id at present
Title: Re: Change Device ID
Post by: akbooer on August 27, 2017, 06:14:19 am
Well, that's a revelation!



...however, I do note that after doing so, the luup.devices structure is NOT updated, and, of course, any running plugins which scan this for device numbers will be completely screwed up.  A reload would certainly be desirable...



...also, if using AltUI, you can simply implement this by directly editing the device attribute "id".
Title: Re: Change Device ID
Post by: michelhamelin on August 27, 2017, 10:09:49 am
I think it is a good ideas when a device failed, re-include device and after switch device ID and delete failed device.
Nothing to change in Lua or scenes.

You can use the following code in the 'Test Luup Code' section (Apps - Develop Apps):

luup.attr_set("id","desired_id",current_id)

Replace the desired_id with the new ID and current_id with the id at present
Title: Re: Change Device ID
Post by: rafale77 on August 27, 2017, 12:22:45 pm
Strongly suggest mcv to implement this function in the UI... well at least I know how to do it now.
I suppose it does not change the next incremental device id of a new device though.
Title: Re: Change Device ID
Post by: jlind on August 29, 2017, 09:41:51 am
I used the luup.attr_set command and it worked as expected.  Everything is good now.  Thanks everyone for the response!
Title: Re: Change Device ID
Post by: kwieto on September 01, 2017, 04:19:55 am
What about changing parent ID?
If I change Id of a master device, where i.e. 2 or more child devices are, will they follow the master?
Title: Re: Change Device ID
Post by: akbooer on September 01, 2017, 05:15:39 am
Good point.  Probably, almost definitely, not.  Although duplicates with the right parent may be created on the next reload.

The fact is that fiddling with device numbers is risky and, frankly, I don't really see why you'd do it, with the possible exception noted by @michelhamelin to avoid scene code changes.
Title: Re: Change Device ID
Post by: kwieto on September 01, 2017, 05:36:55 am
Sometimes it is needed to exclude and include again a device when its configuration changes (i.e. attaching a new sensor). Changing device ID seems to be more simple than digging into the scenes where it is used and modify them.

Another topic is that I have some troubles with Netatmo Plugin, when from time to time some of the devices are recreated with new ID, with no apparent reason.
Fortunately in this case changing device ID should be enough, as parent ID stays the same.

Title: Re: Change Device ID
Post by: Mai Pensato on September 02, 2017, 02:59:29 pm
Question: if you exclude a device, say ID 150 and include it again with new device-ID 201 and then change the device ID from 201 back to 150. So the device nr with the highest ID is then 200.  What if you then include a new device: will it get ID 201 or 202 ?
Title: Re: Change Device ID
Post by: akbooer on September 02, 2017, 03:16:25 pm
Easy to try, but I would guess 202, since there is an independent variable in the user_data which holds the next device number.
Title: Re: Change Device ID
Post by: Cor on September 19, 2017, 03:44:13 am
Someone pointed me to this thread.

I Need to change a Fibaro double relais which is used in some PLEG and scenes:
Parent: #49
E1: #54
E2: #55

How should I use this code for the new relais? , it will be replaced by a double relais from Qubino.
First delete the old fibaro?
Than This code for all 3 (new) devices?
Quote
luup.attr_set("id","desired_id",current_id)

Replace the desired_id with the new ID and current_id with the id at present

Many thanks,
Cor
Title: Re: Change Device ID
Post by: Cor on September 21, 2017, 02:06:13 pm
No one has some more insights in this?

Thanks,
Cor
Title: Re: Change Device ID
Post by: shward1 on September 21, 2017, 04:52:24 pm
This is the procedure I used for a similar device -
Title: Re: Change Device ID
Post by: Cor on September 22, 2017, 02:13:38 am
Ah , ok ..... so just the parent with this "luup.attr_set("id","desired_id",current_id)" . and than with the advanced settings change the ID Manually as well.


But the idea is not to have to update the scenes/ID, since they should than use the ID of the old device for the new device.


When I first make a backup and try this , when it doesn't work and screw things up , I can than use the backup so all is back to it's previous state? . I won't be able to screw up that much with this code and manually change the ID's?

Thanks,
Cor
Title: Re: Change Device ID
Post by: Cor on October 03, 2017, 02:53:14 am
Just tried this . Didn't work. The Parent device was gone and I was left with 2 "appliance modules"....

Thankfully I made a backup  8)


It would be nice if there will be an option to exchange a device easily, these devices don't have an eternal life  :(

Cor
Title: Re: Change Device ID
Post by: michelhamelin on January 08, 2019, 09:49:59 am
You can use the following code in the 'Test Luup Code' section (Apps - Develop Apps):

luup.attr_set("id","desired_id",current_id)

Replace the desired_id with the new ID and current_id with the id at present

Before it was working but now in the address bar it show in red not secure and no change is made.
Why ?
is there another way to do this?