If/Else on Perspective and Error Messages

Hi,

I was wondering if I could get help with changing the state of this valve from an "open" to a "closed" state on perspective.

I am trying to make the valve toggle on a click. As such I attempted to create and if statement that handles this. While, admittedly, I know the if statement is probably constructed poorly - I am wondering why I am getting this error:

Note the code is as such:
def runAction(self, event):

if ({self.custom.example_2} == "closed", self.props.state == "open", self.props.state == "closed")

Expression and Script(python actually) are different.

if self.custom.example_2 == "closed":  # judge equal
    self.props.state = "open"  # assignment
else:
    self.props.state = "close"

Out of curiosity, why not use a button for this?

Thank you so much!

We need it to toggle. Since it is perspective it won't matter if we use a button or a valve. We need the valve and its current state to be shown for simplicity for our operators. Thus, a button would just add more complexity to this design.