Bathroom Logic

I have studied quite a few examples from others but am not stuck. Here is what I am trying to accomplish:
If all lights are on before door is opened various lights come on depending on time of day schedules.
If the lights are manually turned off and the door opens the lights will not go on as long as the door is opened within 10 seconds.
If bath tub light or shower lights are on and no motion for 20 minutes all lights off.
If main light or vanity lights are on and bath tub lights or shower lights are not on, all lights off after no motion for 5 minutes

I haven’t succeed since I get an error message

"Program Logic Event Generator[5] : cBathMain_Vanity and !cBathTubShower and !sTimer5Min and ((cBathMain_Vanity and !cBathTubShower);!sTimer5Min) : attempt to compare two nil values

I am sure I am missing something very obvious

[quote=“jquincy, post:1, topic:187250”]I have studied quite a few examples from others but am not stuck. Here is what I am trying to accomplish:
If all lights are on before door is opened various lights come on depending on time of day schedules.
If the lights are manually turned off and the door opens the lights will not go on as long as the door is opened within 10 seconds.
If bath tub light or shower lights are on and no motion for 20 minutes all lights off.
If main light or vanity lights are on and bath tub lights or shower lights are not on, all lights off after no motion for 5 minutes

I haven’t succeed since I get an error message

"Program Logic Event Generator[5] : cBathMain_Vanity and !cBathTubShower and !sTimer5Min and ((cBathMain_Vanity and !cBathTubShower);!sTimer5Min) : attempt to compare two nil values

I am sure I am missing something very obvious[/quote]

((cBathMain_Vanity and !cBathTubShower);!sTimer5Min)

This is not valid. You can’t do an AND before a another device (there is no single time on both of those devices to compare to the after device). You need to split this up or you need to make another condition with those two devices and merge them.

Forgot my status report.

Anwser is still the same On that error.

@jquincy

As @integlikewhoa indicated you have an error in the logic … that’s also what PLEG is telling you.

The reason is that the arguments to a Sequence expression can ONLY be conditions or inputs.
In your case you are trying to use the expression:
(cBathMain_Vanity and !cBathTubShower)

As argument in a sequence expression where the second term is:
!sTimer5Min

You can create a intermediate condition:
Temp (cBathMain_Vanity and !cBathTubShower)
And modify:
cOffBathMain cBathMain_Vanity and !cBathTubShower and !sTimer5Min and (temp;!sTimer5Min)

NOTE: Temp needs to be Above/Before cOffBathMain in the list of conditions.

@integlikewhoa and @RichardTSchaefer
Thanks to you both I understand it now (I think) and have it fixed

I left out some info.

The reason an expression can NOT be used in a sequence expression is because an expression does NOT have a timestamp.
The sequence expression operate on the timestamps of it’s arguments.