There are probably several different ways to do this and I'm glad you got this working to your satisfaction.
I just wanted to revise what PM had suggested. The code in state #1 is a common mistake for zones. I did the same thing when I first used zones. Revise this code ":state=1:state=0" to
:state=1
,plriwthinzone=0:state=0
and it will work like a charm.
I am sure PM is now hitting himself for this.
THEORY - you know everything but nothing works. PRACTICE - when everything works but don't know why. For me, theory and practice are combined: nothing works and I don't know why.