We have a few UDT instances that have inadvertently had their value change script overridden (through human error). Is there a way to force the UDT instance properties back to inheriting from the UDT value change script?
oh, that would no be possible as far as I know.
Maybe you can do:
1.- Export a tag that you know that has the script the references de UDT, you will see something like this
2.- Run a recursive and append all tag path where you find something different than expected. (Add a filter to only check tags witch belong to your UDT name)
3.- I would compare if you find the key “eventScripts” and also the “script” value itself. If theses are different so it means it was overriden.
4.- Ones you have your list of paths, sadly. You’ll need to manually disable the “overriden”
jq could probably do it; it’s pretty easy if you don’t care about any event scripts, just delete the entire eventScripts node for everything under a UDT instance.
If you know that it’s the only thing overridden, then using jq you could only apply your deletion if the object contains just the name and tagType members, then you won’t be affecting other tags with actual scripts
I ended up using a hackish way to achieve this by resetting the entire tag to the UDT definition then writing back values that I want to preserve. Not ideal but definitely better than manually resetting them. jq looks pretty slick. Will definitely check it out.
tags = system.tag.browseTags(parentPath="[default]Devices")
preserve = ['io_device_id','io_device_name', 'map',
'map_x','map_y', 'voice_alert','notes']
for tag in tags:
cache = {}
for p in preserve:
path = tag.path + '/%s' % p
val = system.tag.read(path).value
cache[p] = val #store preserved tag value
reset = {'name': tag.name}
system.tag.configure(tag.path, reset, 'o') #reset the entire tag
for p in preserve:
path = tag.path + '/%s' % p
system.tag.write(path, cache[p]) #write back previous value