Write Value to Tag using Pushbutton Script

I'm pretty new to ignition.

Looking to use an onClick event to write a value to a tag using a push button. Does the script below look correct or is there something that i'm missing. Thanks in Advance!

def runAction(self, event):

										 params = {
												 'deviceTagPath':[RiversideWTPProvider]HighService/HSP No1 Check Valve/OPEN,

I see the creation of a params dictionary and nothing else. So the dictionary will be created, then discarded at the end of the script. Your script should look more like:

	system.tag.writeBlocking(['[RiversideWTPProvider]HighService/HSP No1 Check Valve/OPEN'], [1])

Note the placement of the tag path in a string, and both tagpath and value placed inside square brackets to make one-element lists of each. (See the docs for writeBlocking for why that is.)

Also, you should not use click events on buttons, as they don't respect the button's enabled/disabled state. Use the actionPerformed event instead.

1 Like

Thank you for the insight!