Lighting rule Not Working

Hi All

I'm New to Hubitat after my Fibaro HC2 died after 4 years.
Quite glad really as it never lived up to the price tag, and Hubitat is much more more fun to use.

So far most things i have tried are working well, but with this one rule i'm missing something, as it just will not turn off my lights

image

When it runs at midnight it logs the following

2019-09-14 00:00:01.704 infoAction: END-IF
2019-09-14 00:00:01.696 infoAction: Off: Christmas Lights Garage, Outside Study Lights, Outside Wall Lights, Outside Garage Lights, Christmas Lights House (skipped)
2019-09-14 00:00:01.667 infoAction: ELSE (skipping)
2019-09-14 00:00:01.659 infoAction: END-IF
2019-09-14 00:00:00.852 infoAction: On: Outside Study Lights, Outside Wall Lights, Outside Garage Lights
2019-09-14 00:00:00.828 infoAction: ELSE (do actions)
2019-09-14 00:00:00.822 infoAction: On: Christmas Lights Garage, Outside Wall Lights, Christmas Lights House (skipped)
2019-09-14 00:00:00.782 infoAction: IF (Between December 1 and January 6(F) [FALSE]) THEN (skipping)
2019-09-14 00:00:00.568 infoAction: IF (Time between Sunset and 23:59(F) [FALSE]) THEN
2019-09-14 00:00:00.347 infoOutside Lights (Sunset - Midnight) Triggered
2019-09-14 00:00:00.325 infoOutside Lights (Sunset - Midnight): Triggered at Certain Time

Although the first IF is false it seems to run the else from the second IF and skip the actual else from the first IF.

Can someone point out what i'm doing wrong please ?

Cheers
Mike

I would do the actions differently.
If the time is between sunset and 23:59 and
date is between dec 1 and jan 6
then
on lights ....
else if time is between sunset and 23:59 and
Date is NOT between dec 1 and jan 6
then
on lights...
Else if
Time is between 23:59 and sunset then
off lights ..
end if

There's really no perfect way, but using that end-if in the center makes the rule not know what condition it is testing for. And the if then statements have me confused, but I like straight forward defined logic so that I can relate to it later, so I, Personally, stay away from the else with no (for lack of a better word) explanation of what should be happening.

I agree with April. I think it is the second IF>THEN that is messing this up. It should be an AND.

I never can decide when to use ELSE vs ELSE IF, but I would think that ELSE IF would be the more appropriate choice in the second statement. Like April notes, that would give you the separate action on these dates. I could also see making this a separate IF (not ELSE IF) and saving the ELSE IF part for the 3rd statement.

Not sure this is better than April's version, but it is how I would try things.

IF time is between sunset and 23:59 AND
date is between dec 1 and jan 6
THEN
on lights
END IF

IF time is between sunset and 23:59 AND
Date is NOT between dec 1 and jan 6
THEN
on lights
END IF

ELSE IF Time is between 23:59 and sunset THEN
off lights ..
END IF

I fee like this should be an If statement because it's alone. else and elseif I feel lilke they go in when there is one statement grouping. But I never know when to use it either. Just doesn't look right to me.

Googled it:
Use if to specify a block of code to be executed, if a specified condition is true. Use else to specify a block of code to be executed, if the same condition is false. Use else if to specify a new condition to test, if the first condition is false.

So If I am interpreting that correctly, the second statement is an ELSE? Then the third would be an IF?

I have used all IF before and it worked. Maybe I got lucky and things just didn't conflict or whatever? :thinking: :astonished:

Story of my life. :slight_smile:

Thanks for all the reply's, i'll split the conditions as suggested and see what happens.

I have to admit it still feels like there is some sort of bug in the Rule Machine, I have seen lots of rules posted with nested if's like this and since Rule Machine allows you to enter nested if's then surely they should work, unless i'm missing something else

I don't see an issue with the rule at all. If that first IF fails...which it did. It should skip down to the ELSE for THAT IF. Not the nested one...which is what it looks like it did. From what I see that's correct. According to your logs the first IF evaluates FALSE then it shows (skipping) the next nested IF which it should...skips the ON action but does NOT skip the ELSE. It's as if it's using the ELSE statement for the first IF statement and not the nested one. That's my read of it.

Yes it seems to be relating the else to the wrong If.
I guess there cannot be a generic problem with nested ifā€™s as people are using them all over the place.
I will try recreating the rule from scratch and see what happens

Here's an option that'll eliminate the nested loop.

Trigger:
When time is Sunset

Action:
IF (Between December 1 and January 6) Then
    On:  Christmas Lights Garage, Outside Wall Lights, Christmas Lights House
ELSE
    On:  Outside Study Lights, Outside Wall Lights, Outside Garage Lights
END-IF
Wait for events: When time is 00:00  
Off:  Christmas Lights Garage, Outside Study Lights, Outside Wall Lights, Outside Garage Lights, Christmas Lights House

The original rule I had was basically that, but since I was doing most of my playing in the evening after sunset, if I restarted the hub for any reason then the lights stayed on all night.
So thatā€™s when I changed to the two triggers

Interesting, my Waits aren't reset by a hub reboot so I posted that as an option. Your original rule looks fine to me so I don't understand why the nested ELSE was run. Hopefully your recreation of the rule will work. Good luck!

Ok thatā€™s interesting too, I was pretty sure I saw a pattern of reboots and lights not turning off, but maybe it was just coincidence and it was something else
I definitely play with the waits again. Cheers