System.tag.configure change folder to tag

I am trying to turn a folder in tags to a String tag using system.tag.configure. system.tag.configure is returning Good, but the tag just stays as a folder. I am I missing something?

I have a folder at with nothing “[tagProvider]myFolder” in it. I then run the following and nothing happens with the tag but it returns Good

tag = {
		"name": "state",
		"valueSource": "memory",
		"dataType": "String",
		"tagType": "AtomicTag",
		"value": "myTestString"
}

system.tag.configure(basePath = "[tagProvider]myFolder", tags = [tag], collisionPolicy = "m")

The strange thing is that if i then run system.tag.getConfiguration I can see the configuration has changed, but the tag still looks like a folder in the browser tree.

refreshing or restarting the tags does not change anything, but if I go to the gateway page and got to the tag provider and edit and save it the tag will then change from a folder to a string tag.

version 8.0.12

@Jonathan

While the definition of the tag is changing, the changing the tagType from a Folder to an AtomicTag is something that the system doesn’t expect and Ignition isn’t written to handle this type of change in the manner you are looking to achieve it. In fact an error is thrown if you use system.tag.getConfiguration and attempt to change the tagType key from Folder to AtomicTag and resubmit.

The way I would advise doing this is:

  1. Getting the configuration of the existing folder using system.tag.getConfiguration
  2. Make the changes to that config, dropping the tagType key
  3. Delete the tag
  4. Submit the new configuration

This will leave the system in a much more predictable state. I have provided a working example below. Keep in mind that this will delete the folder (and potentially anything contained in it) before writing the new tag. You will want to add code surrounding this to ensure that a tag creation failure doesn’t lead to disastrous results for your system.

basePath = '[tagProvider]myFolder'
tagName = 'state'
tagPath = '{0}/{1}'.format(basePath, tagName)

config = system.tag.getConfiguration(tagPath)[0]

config[u'valueSource'] = u'memory'
config[u'dataType'] = u'String'
config[u'value'] = u'myTestString'
del config[u'tagType']

system.tag.deleteTags([tagPath])
system.tag.configure(basePath=basePath, tags=[config], collisionPolicy='a')
1 Like

Thanks, I should be able to make this work.