Toggle with PLEG

I am trying to Toggle a lamp if Variable Container switches to 1 and then set the variable container back to zero.

I am trying:

ToggleLightOn = (ToggleFlag==1) AND LightOff
ToggleLightOff = (ToggleFlag==1) AND LightOn

either of the above work on their own… However, I am using PLEG to (a) flip the light and (b) change the Variable Container change ToggleFlag’s state to zero. The time that it takes to (b) creates a condition where both ToggleOn and ToggleOff are true and it bounces.

I tried to put some time in there:

ToggleLightOn = ToggleFlag AND LightOff AND (LightOff;NOW>1:00)
ToggleLightOff = ToggleFlag AND LightOn AND (LightOn;NOW>1:00)

Doesn’t work.

Any suggestions on toggling from a Variable container flag and updating the flag?

Conditions
NewStatus LightOn ? 0 : 1
DoToggle ToggleFlag == 1

Actions
DoToggle VariableContainer SetVariableX newVariableX=“0”
Light SetTarget newTargetValue={(NewStatus)}

cheers mate

my first use of the PLEG ternary :slight_smile:

For some reason to make it reset reliably, I had to write the “0” with lua. Strange; perhaps some kind of configuration issue with my arduino ‘light’ device, but I reckon I have had that happen to me before.