Static tokens for items files

Just a quick one guys…
Is it possible to create a token (like a variable) for the channel ID and have that replicate throughout an items file?
I’ll explain… Every time I do a fresh install or reset my Z-Wave controller I get a brand new channel ID, meaning I have to copy and paste the new ID into all my Z-Wave item definitions, this is same for other items too.
If we could get a static token then we could just edit that token and all the items would adopt the new ID. Would save a lot of time.
I have looked and cannot find such a solution. Maybe I answered my own question, lol.

If you use items file, what about find & replace with any text editor? It’s just 4-5 clicks and all your items are updated …

And even if using UI method, you could bulk change that ID by shutting down openHAB and afterwards doing a shell command like this:

grep -l oldID $OPENHAB_USERDATA/jsondb/ | sudo xargs sed -i 's/oldID/newID/g'

but be aware that this command will change ALL appearances of oldID to newID in the whole configuration of openHAB, so maybe it’s a good idea to first backup all configuration, just in case… :wink:

That’s what I do now, but sometimes I miss ones that are in different items files. I can imagine it being worse for people with very large amounts of devices and files.

This does not have to be, just add your controller Thing with „custom id“, using your „old“ id. You then don‘t need to change your channels.

I’ll mark this as the solution since it best achieves what I want.

1 Like

Just for completeness: even with notepad++ you can find& replace in all files within a folder, so you will not miss a file. But the solution from hmerk is of course better