Lights on if motion already active when mode changes

So I turned all the Evening mode lights off. Switched mode back to Day. Enabled logging in all my ML apps. Waited until all motion sensors had cleared. Opened all the ML apps status pages in separate tabs so I could screenshot any that misbehaved, then changed mode to Evening again and.............. Everything ran perfectly and none of the ML lights came on! It's like it knows it's being watched!

Anyway I will keep the logs running in the ML apps, so that if it does it again, I will have something to check.

Ok so today all 4 ML lights came on wrongly when the mode changed and I had logs running so here they are for Bed1 & Bed2.

!

I don't see anywhere in those logs where Motion Lighting turned those lights off. It says "Not turning off, wrong mode Day", and "Not turning on, wrong mode Day". So the question is, when did Motion Lighting last turn the lights off, or know that they turned off? Also, as before, pretty much need to see the app status. I'd say it appears that Motion Lighting thinks the lights are on. Why that is is not clear. If Motion Lighting thinks the lights are on, and you have it set to adjust for mode changes, then it's going to do just that. The root cause of this is not shown in these logs, just the consequence. Also, could you please show the Motion Lighting main page for this? There is lots of context you are familiar with but not showing.

I am not able to reproduce this failure, but I don't know how you have things setup.

I'm not saying ML turned them off, it is turning them on when it shouldn't - at mode change when no motion is active.

The top line in the Bed 2 log is ML turning on the light at 2:34pm (mode change time) even though motion is inactive from 2:12pm (2 lines down in the log).

Motion lighting won't have turned the lights off since the previous day as it is only active in Evening Mode.

To me the ML app is behaving as if the motion is active when the mode changes when it actually isn't.

I have posted the ML app status pages earlier in the thread but as you need them just before this error occurs and I can't know which app is going to misbehave (it can be some or all) it is hard to log the details. But I think the logs above prove that the ML app isn't doing what it should.

This is the current status page for the Bed2 ML app

I think one went missing in transit,

I understand, but it thinks the lights are on, so I'm interested in when it turns them off or when they got turned off by some other means.

From app status, need to see Application State, not Settings. And need to see it from before the mode change.

No, it's acting as though the lights are already on at mode change. You must have it set to adjust the light levels at mode change. It knows whether or not to do this based on whether or not it thinks the lights are on at that moment. If it thinks they are on, then it does the level change. If they are in fact off at that moment, the level change turns them on. So, one obvious thing I can change is to not base turning them on based on what it "thinks", but on the actual state of the lights.

I don't understand why you think it thinks the lights are on.

The log before the mode change shows "Not turning on :wrong mode Day" at the last motion detect. Doesn't that mean it know the light is off?

app:7372018-12-21 02:56:28.786 pm infoTurning on switch [Bed 2 Lamp TB]

app:7372018-12-21 02:56:28.750 pm infoMotion active Bed 2 Sensor

app:7372018-12-21 02:34:16.151 pm infoTurning on switch [Bed 2 Lamp TB]

app:7372018-12-21 02:12:27.055 pm infoNot turning off: wrong mode Day

app:7372018-12-21 02:12:27.043 pm infoMotion inactive Bed 2 Sensor

app:7372018-12-21 02:03:45.644 pm infoNot turning on switch: wrong switch mode Day

app:7372018-12-21 02:03:45.622 pm infoMotion active Bed 2 Sensor

This is the main page of the Bed2 ML app.

I don't think they are on, the app does.

No I'm saying I don't know what makes you believe that the app thinks they are on. The logs to me suggest the app knows they are off.

That's a supposition on my part, and why I want to see the app state before the mode change that causes it. That's the only thing that would explain the mode change turning on the lights.

So I want to attempt to understand why it thinks that the light is on. The light turning off earlier should have set that correctly, so this is a mystery.

Wouldn't it thinking that motion was active when mode changed cause that behaviour too though?

No, it has nothing to do with motion, unless there is motion. The code for a mode change only looks at one thing, whether or not the lights are on. If the app thinks they are off, nothing happens. There is no other thing that happens due to a mode change --- it's literally one line of code. As I said earlier, I've put in a change to also check whether or not the light is actually on, in addition to what state the app thinks it's in. It's not at all clear how the app could think the light is on when it's actually off, but, you are seeing what you are seeing, and I can't tell what's going on from here.

I'm now very confused.

If we go back to my original question in this thread was that in Motion Lighting apps if the mode changed to the active mode while motion was already active I wanted the lights to come on. I thought that by you adding the "change level on mode change" option as you did that was exactly what it did. In fact it works exactly like that some of the time.

But now you are saying that what is happening is nothing to do with motion, when I thought that whether the lights come on at mode change was now totally dependant on if motion was already active or not?

Looking back at original post and my response, I misunderstood what you were asking.

What the app is supposed to do as currently implemented is not what you were seeking. The option for mode adjust changes the levels at mode change if the lights are already on. What you want is for them to turn on at mode change if motion is active. As long as I’m poking at this bit of code, I can add that test for the mode change logic.

That doesn’t address the anomalous behaviour you are citing where the lights turn on at mode change without motion.

Ah, Ok, that explains my confusion.

The really wierd thing is that when I first tested your changes, I tripped motion on one of the rooms before the mode changed then when I switched mode with motion still active, it came on as I wanted, and I'm pretty (but not 100%) sure that those that I hadn't tripped, didn't come on.

Sounds like that was just a fluke occurance of the odd behaviour that I am still seeing now. Certainly had me fooled that it was doing what I wanted though.

How your head doesn't explode trying to work all this stuff out is beyond me!

I've just bitten the bullet and replaced all my ML apps with RM rules. The final straw was having another issue with one of the ML apps that was turning the light off when motion became inactive, even though it was already switched on before the motion became active and I had the "Don't switch off if already on" option selected.

I don't know why I've had so many issues with ML, maybe I was just forcing a square peg into a round hole, but it never seemed to do exactly what I wanted reliably. I think, as you have suggested, it seems that ML sometimes has an inaccurate record of whether a light is already on or not.

It has taken 3 RM rules to replace each ML app, (Motion On/Motion Off/Mode change) but with the use of private boolean on Motion Off to make sure they only turn off when motion has turned them on in the first place, I now have them doing exactly what I want. This includes turning on at the appropriate Mode change if motion is already active and still turning off if the Mode changes away from the "live" one between motion going active and inactive.

I've left all my ML apps paused rather than deleted so I can still do testing on them in the future if required.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.