Change tag ParameterValue

Hi,

I would like to change a ParameterValue I’ve called “nb_hours” in a UDT instance tag.

Example :

configs = system.tag.getConfiguration("[test]pathtomytag",True)

configs[0]['parameters']['nb_hours']['value']=5

I have an error “‘com.inductiveautomation.ignition.common.tags.config.properties.ParameterValue’ object is unsubscriptable”.

Can you help me ?

When you run system.tag.getConfiguration, it returns a list of tag dictionaries related to your tag. You can’t just write back to that list. You can take that list and modify it then use system.tag.configure() to write back to your tag. The last example in system.tag.configure looks close to what you were trying to do there except you added [‘value’] to it so I’m assuming you have more to your script your not sharing?

Thanks
It's not for UDT Definitions but for UDT instances.

Below my try :

path="[test]pathtomytag"
configs = system.tag.getConfiguration(path)

configs[0]['parameters']['nb_hours']=5
print configs[0]['parameters']

system.tag.configure(path, configs, 'o')

Return :

{u'device_id': {datatype=String, value=17}, u'nb_hours': 5, u'serial_number': {datatype=String, value=null}, u'device_name': {datatype=String, value=null}, u'database': {datatype=String, value='db'}, u'project_id': {datatype=String, value=2}}

[Bad_Unsupported("The target path '[test]pathtomytag' does not have item 'pathtomytag' for overrides, and cannot accept children tags.")]

I don’t have an 8.0 system in front of me right now to try it out but what about something like:

path="[test]pathtomytag"

param = {"parameters":{"nb_hours":5}}

system.tag.configure(path,[param],"m")

Instead of trying to update everything about it, I’m just specifying the parameter you want to change and then using the “m”(merge) collisionPolicy.

With your code I have : [Error_Configuration]

Hi,

My script still not work. I didn’t found any solution for instance.
Do you have a solution ?

Hi,

Do I have to upgrade Ignition to fix this problem ?

Thanks,

Pretty sure you need to pass the parent path to configure, not the path to the actual tag

Here we go

EG set basePath to
'/'.join(path.split('/')[:-1])

You could probably also use a proper tag path library to get the parent path as well… Just in case your tagpath doesn’t contain any folders

1 Like

I had the same issue in a script I wrote before Inductive added datatypes to UDT parameters. You can no longer just assign a value directly to a parameter. You’ll need to use the “setValue” method.

So change your script to this:

configs[0]['parameters']['nb_hours'].setValue(5)
1 Like

The other thing is that you can simply write to the UDT instances’ parameters directly using system.tag.writeBlocking(['path/UDTInstance/Parameters.Param1'], [10])