Tag Change script works as normal tag but not as UDT tag

I have a tag change event that based on one tag will disable or enable other tags. This script below works under normal circumstances but as a UDT it will not work. The script below is defined in my Project Library and I call it from the tag change event.

def SetEnabled(tagPath, value):
	system.tag.editTag(tagPath, attributes={"enabled": value})

As a UDT it produces the following in the log.

Error publishing tag change event.

java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: java.lang.String. Forgot to register a type adapter?

at com.google.gson.internal.bind.TypeAdapters$1.write(TypeAdapters.java:73)

at com.google.gson.internal.bind.TypeAdapters$1.write(TypeAdapters.java:69)

at com.google.gson.TypeAdapter$1.write(TypeAdapter.java:191)

at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69)

at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97)

at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61)

at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69)

at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127)

at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245)

at com.google.gson.internal.bind.ObjectTypeAdapter.write(ObjectTypeAdapter.java:107)

at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69)

at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127)

at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245)

at com.google.gson.Gson.toJson(Gson.java:704)

at com.google.gson.Gson.toJson(Gson.java:683)

at com.google.gson.Gson.toJson(Gson.java:638)

at com.google.gson.Gson.toJson(Gson.java:618)

at com.jnjdodev.ignition.modules.websocket.UtilSingleton$1.tagChanged(UtilSingleton.java:92)

at com.inductiveautomation.ignition.gateway.tags.subscriptions.ProviderSubscriptionManagerImpl$TagChangePublish.run(ProviderSubscriptionManagerImpl.java:1093)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Maybe I need to do it using something with the overrides?

I would suggest using a Leased Tag Group and disable the pulling (set to 0) when not on screen, and toggle the display with Roll_1_Installed.

1 Like

I think that only applies to perspectives right? We have our own web HMI so I’m not sure leased applies. That being said I do have a solution worked out. Looks like the overrides tag edit did the trick

My new method for enable disable is below. Seems to work great! Thank you for the input!

def SetEnabledUDT(udtTag, tagPath, value):
	system.tag.editTag(udtTag, overrides={tagPath:{"enabled": value}})

The leased works with Vision and Perspectives (Ignition clients). If you are only using Ignition as a OPC-UA Server only, I’m not sure if the Leased mode would work, maybe @PGriffith has a better answer for you here.