[IGN-5824]Ignition - Gateway shelf Alarm script

The system.alarm.shelve implementation is hardcoded to use gateway-script as the user ID, likely because it long predates Perspective, and thus there would never be multiple users interacting with the gateway. We can and will amend that to allow for passing more information in, but, in the meantime, you can work around it fairly easy.
You'll need to get a GatewayContext - there's examples floating around the forums on how to do that, or you can use Ignition Extensions, my unofficial set of useful scripting modules. Once you have a context, all you have to do is:

from com.inductiveautomation.ignition.common import QualifiedPath

def shelve(paths, timeout, userName):
    paths = [QualifiedPath.parse(stringPath) for stringPath in paths]
    user = QualifiedPath.Builder().setUser(userName).build()
    gwContext = # obtain a gateway context
    gwContext.getAlarmManager().shelve(paths, timeout, user);

4 Likes