[IGN-5824]Ignition - Gateway shelf Alarm script

I have an alarm script used to shelf alarms, and this script runs on the gateway.
It works like a charm, except that the alarm always shows as "shelved by :gateway script" in the "Shelved alarm" view.

Is there a way to add the user info instead of the "gateway script", so that it is possible to see who shelved the alarms?
(I have the user info available, just can't seem to find anywhere to insert it).

If you run the script in perspective (client side) does it have the same 'shelved by'?

Otherwise, maybe using the Notes property could give you the same affect.

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

Thanks @PGriffith , I'll try this one with your extension modules.

The "paths "input on the function, what data is expected there?
and the timeout, is that the shelving time in minutes?

The paths argument should be interpreted just as it is for the system.alarm.shelve function. The timeout argument is in seconds.