2 State Toggle Button Conditions

If I have a tag (toggle_tag) tied to a 2 state toggle button to toggle it true/false, but have another tag (alarm_tag) that when true should immediately set toggle_tag to false and not allow it to be manually toggled back to true until alarm_tag goes false, what is the best way to accomplish this thru the 2 state toggle tag’s properties?

You could add a ValueChange event script to the alarm_tag so that when it goes from False to True, you set toggle_tag to False:

	if initialChange:
		return
		
	if previousValue.value == False and currentValue.value == True:
		system.tag.write("[.]toggle_tag", False)

In your 2-State Toggle button just bind the enable property to the inverse of the alarm_tag value:

!{alarm_tag}
1 Like

You could also bind the enabled property of the button to the alarm_tag.

That's the opposite of what @lonegator wants:

not allow it to be manually toggled back to true until alarm_tag goes false

And lacks this bit:

but have another tag (alarm_tag) that when true should immediately set toggle_tag to false

1 Like

Right, I didn’t notice that you had already mentioned binding the enabled property to the alarm_tag. I intended for the reader to intuitively understand that I meant an expression binding to the inverse of the value of the alarm_tag, because it’s easier to say “bind it to the alarm tag” than to say “bind it via expression tag to the inverse of the alarm tag”.

Anyway, my mistake.