Open dock on active alarm

This thread lead me to the answer as I finally realized it is no different from a common alarm pop-up use case :

@cmallonee supplied a function that got the community started.
@wakatipu discovered that (On Ignition Edge designer 8.1.22) if the designer is running the code would exit the for loop before getting to the true sessions so the designer was excluded.

 if session.userAgent != "<designer>":

This is the script after reworking it for docked view system functions:

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	dockId = "alarm" #dock ID
	logger = system.util.getLogger("dock") #optional logging 
	sessions = system.perspective.getSessionInfo()
	for session in sessions:
		for pageId in session.pageIds:
			logger.info("{0} | {1}".format(session.id, pageId))
			if session.userAgent != "<designer>": #exclude designer
				if currentValue and currentValue.value:
					system.perspective.openDock(dockId, sessionId=session.id, pageId=pageId)
				else:
					system.perspective.closeDock(dockId, sessionId=session.id, pageId=pageId)

(I also ditched my gateway script to evaluate active alarms for a Boolean reference tag on [System]Gateway/Alarming/Active and Unacked as I have only one project on this Gateway)

2 Likes