I need to make changes to a tag group on 15 gateways connected via the GAN, but can't do this through the EAM since it's a gw configuration which can't be sent I don't want to connect to 15x designers to change this since i'm lazy and that's a LOT of logging in. Hence..
Maybe this will help someone...
This will create or replace a tag group called "Test" set to Direct mode, OPC Polled (not subscribed), @ 1000ms.
import traceback
from com.inductiveautomation.ignition.gateway import IgnitionGateway
from com.inductiveautomation.ignition.common.tags import config
from com.inductiveautomation.ignition.common.config import PropertyValue, BasicPropertySet
from com.inductiveautomation.ignition.common.tags.config import CommonTagGroupProperties, TagGroupMode
from com.inductiveautomation.ignition.common.tags.config.types import OpcTagGroupProperties
from com.inductiveautomation.ignition.common.sqltags.model.types import OpcDataMode
try:
# gets the tag provider object
provider = IgnitionGateway.get().getTagManager().getTagProvider('default')
# gets the existing tag groups objects -- not actually used in the rest of the code
tagGroups = provider.getTagGroupsAsync().get()
# create a new tag group which is just a basic property set
newTagGroupConfig = BasicPropertySet()
# add properties into the property set that relate to the Tag Group configuration
# first set the Tag Group's name
newTagGroupConfig.set(PropertyValue(CommonTagGroupProperties.Name, 'Test'))
newTagGroupConfig.set(PropertyValue(CommonTagGroupProperties.Mode, TagGroupMode.Direct))
newTagGroupConfig.set(PropertyValue(CommonTagGroupProperties.Rate, 1000))
newTagGroupConfig.set(OpcTagGroupProperties.OPC_DATA_MODE, OpcDataMode.Polled)
# create a new tag group configuration object
newConfig = config.TagGroupConfiguration(newTagGroupConfig)
# add/replace the new tag group to the gateway
result = provider.saveTagGroupsAsync([newConfig]).get()
system.perspective.print('Result: {}'.format(result))
except:
system.perspective.print(traceback.format_exc())