Motion Lighting turns lamp off in wrong mode

Yesterday I set up 2 new motion lighting apps, both very simple. In Evening mode only switch on with sensor and then after a 1 min delay switch off. Don't switch of if lamp was already on. Both instances are coming on correctly, but are both turning off, not only in any mode, but also when the lamps are already on. E.g. this morning we are reading in bed and the bedside lamp that we have switched on manually gets switched off 5 mins after any movement is triggered. Mode is Daytime.

I've just tested my only other Motion Lighting App, which already existed and that does the exact same thing. I hadn't noticed the problem before as that lamp only ever gets used in motion sense mode, but if I turn it on first then the sensor senses movement it turns the lamp off after the preset time even though it's not the specified mode AND the lamp shouldn't turn off when it's already on anyway, so it's a double bug.

I guess people must be using RM rather than the Motion Lighting App or surely this would have been spotted before?

1 Like

Just wondering, does the lamp show as "on" in Hubitat before you do this? Just asking because some switches won't automatically update their state (e.g., the non-Plus GE Z-Wave in-wall switches, and Hue takes a minute or so to update from what I've seen, possibly because it's just polling), so maybe Hubitat doesn't think it's on. And, of course, if you're reaching for a switch in the same room, it's likely the motion sensor will see you before it gets turned on.

But it could be a big. I'm using webCoRE and a custom app for most of my lights, and my only Motion Lighting automation doesn't use this feature. :slight_smile:

The lamps show up as on fine in Hubitat. In fact I'm switching them on via Hubitat dashboard not a physical switch. But it's also the fact that the "off" part of the routine is apparently working in all modes, not just the one it is meant to. I've rewritten them in RM and all seems to work OK now, it's just that Motion Lighting App is a little bit quicker and easier to program, so I would still prefer to use that if it worked. Also I'm getting a lot of RM rules now and it's nice to have the Motion Lighting ones all in one area.

I will look into this. Could you kindly post screen shots of the main page of these two Motion Lighting apps?

This function, don't turn off if already on, depends on sensing the physical on of the device. What sort of lamp is it? Is it a switch, dimmer, bulb? Please be specific. It is possible that this is failing due to the device not sending a "physical" event. We'd have to find some other way to disable turning it off without that bit of information from the device. That is, the app has to sense the light being turned on outside of the app.

One thing to bear in mind, is that Motion Lighting has separate settings for turning on and turning off. You would have to set the Off option, Modes to Disable Turning Off, for it to not turn off in the other modes besides the one you have it set to turn on in. That's a bit backwards I suppose. But, if you set that for every mode except Evening, then it won't turn off in Day mode.

Really? That's a bizarre way of doing things. Why on earth would you want the off command to work in anything other than the same mode as the on? I guess that explains what I'm seeing, but I have to say that IMO it is illogical enough to effectively be a bug.

This cuts both ways. One use case is that you only want the lights to turn on in Day or Evening mode, but you want them to turn off after the mode changes to Night. In other words, there is no single answer to how it should work. This is the reason that options for On and options for Off are separated, and apply independently. There is no other way to accomplish both possible outcomes. You can control when or when not motion activates a light, and you can control when or when not motion going inactive turns it off again.

1 Like

Fair point. Perhaps the best answer is for the "off" command mode(s) to default to the same as the "on", unless specifically defined otherwise. That way users like me who aren't even aware of the option, get the functionality they expect, but the option to change is still there for advanced control.

The lamps in question are all plug in TBK units. 2 are dimmers, 1 is a switch. None of them are ever switched with a physical switch, only ever via Hubitat dashboard, RM rules or a Remotec ZRC90 8 button remote. They always show their state correctly in Hubitat. All 3 Motion Lighting rules would still switch off the lamp even if it was on prior to the first motion event. I checked the Motion flag was clear before switching the lamps on (via dashboard), then walked into the appropriate area, to trigger motion. After the preset delay the lamps were switched off. I have since switched them from Motion Lighting to RM instead, but could easily recreate them if required. I think it will be easily repeatable for you to test though as all of mine did the same.

This is easily explained when looking at how Motion Lighting is implemented. It is looking for physical events to set the condition for "don't turn off when already on". Obviously, your devices are not throwing such an event.

I will look into changing the implementation to examine the conditions in another way to make that determination.

Ah, so the Motion Lighting App definition of "light already on" is only looking for a physical switch action and isn't the same as an RM rule that only fires when the light is off? That's what I'm now doing and it works as I expected.

Actually, digging into the code a bit, it doesn't seem to require "physical" after all to recognize that the lights are already on.

Update: Now I can't reproduce the problem. The first time I didn't have the "don't turn off if already on" flag set. Doing it again, it didn't turn off the light.

Since you don't have this Motion Lighting rule installed anymore, it's sort of impossible to troubleshoot what might have been going on. Let me know if you want to check this out again, would be glad to help find the issue.

I have recreated the error. This is a screenshot of my Study routine. If I turn the study lamp on with dashboard then walk into the room, after the delay the lamp goes off.

Could you please do this:

Trip the motion sensor, and then take a screenshot of the app detail page (circle i on Apps page for that Motion Lighting rule). I'm looking for a Setting called "DontTurnOff" near the top of the page and a State variable called "alreadyOn" near the bottom of the page. Post screenshot here.

Oh, and turn on the light before, like you did before.

Here you go.


Interesting. The alreadyOn state variable is not set. That explains why the light turns off again.

I see the problem in the app. It was setting that state only for dimmers, not switches, and your Study Lamp is a switch! This will be corrected in the next release.

Thanks for bringing it to my attention.

5 Likes

Glad you found it. :+1:

This bug has been fixed in the latest release: Hub Update 1.1.3

1 Like

I think the bug fix may have created an inverse bug. I've just tried another Motion Lighting App and now it seems that if you select the "don't turn off if already on" option the lamp never turns off even though it wasn't on before the motion trigger. I've tried with both dimmers and switches and it behaves the same for me. It's not the mode stopping it turn off, because as soon as I deselect the "don't turn off if already on" option it all works as it should. The lamps in questions show correctly as off in dashboard before the motion trigger turns them on.