Else If not working as expected for shutting lights off


#1

1) Give a description of the problem
The Else If portion isn’t reliable. I think it’s really with the Away status. It seems that if I’m home, the lux portion works. But I frequently check my home by CCTV when I’m away and the lights that were on when I left are still on. I’m not sure if it works when the lux changes when I’m not home, I hadn’t thought to really pay attention to that.

2) What is the expected behavior?
Lights turn off when I’m not home or when it gets light out.

3) What is happening/not happening?
The lights do not turn off reliably when I’m away.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS)

Haven’t captured logs yet… but I figured I’d ask if there were any obvious logic flaws in the way this is set up, if that isn’t it, I’ll get the logs.


#2

Try moving your else if to it’s own if statement. I think the first if is negating the else if


#3

In the WITH to turn the lights off, change TCP (Task Cancellation Policy) to never.
You can find this by clicking on the WITH, scrolling down to the settings cog and you will find where you can change it. You may also want to change your turn off statements to run async.
I think your problem may be that every time the lux value changes, even if it is greater than 15, the piston re-evaluates and restarts the timer. Therefore the task will cancel and the timer restarts.
Try what I suggested and see how it goes.


#4

Hmmm… well, I have that countdown to give me a bit of a buffer for when the lux is right around 15 and bumping up and down. I don’t want the mood lighting flipping off and on a lot. So I had that 5 minute slop time built in so that I know that the house is below 15 and most likely staying there. I assume changing the TCP will negate that functionality?


#5

What it means is that while the lux value is greater than 15 the timer will start and mature.
Which is not what is happening at the moment.
What might be a better idea would be to change your ‘Is Greater’ than 15 to ‘Stays Greater Than 15’ for x minutes. This is a trigger which means you will have to change your conditions to ‘Always’ subscribe.
Hope this makes sense.
If not I can knock one up to show you what I mean.


#6

Something like this.


#7

I’ll have to give it a try. Basically, I’m trying to have all that stuff turn off if the lux gets above 15 OR I’m away.

No need to worry about that 5 vs. 7 minutes chunk. That’s not important, I’m really just worried about getting that above logic right.

Turning on is always perfect right now
Turning off is usually good when light drops if I’m home
Turning off gets flaky when I’m not home

The lights should always be off if I’m not home, right now it looks like whatever was on when I left stays on.

And thanks for the help so far! This is the same thing I struggled with since the days of CoRE. Getting something to turn off reliably based on light OR me leaving

I’ll try the stays and use OR with the away statement, hopefully that’ll do it?


#8

I actually think I sorted it… and now it all seems so obvious.

My very first IF for illuminance isn’t mode restricted, instead, the actions were. So I think the IF was fighting with the ELSE IF in that regard. Yesterday I added AND mode is HOME to the initial IF and then watched my camera and the lights turned off. I’ll monitor today when my wife leaves and see what they do.