[RELEASE] Lights on Motion Plus (dim before off, remember individual bulb states, etc.)

The lights will turn on to whatever they were on the last time the app turned them off (specifically, it saves their on/off state and, if on, their brightness level, then restores these the next time motion is detected; it stores both to only turn back on bulbs that were on before but also because it dims them and the bulb itself won't remember it's "real" previous level, only the dim one).

My idea for how it would work is that i set the lights the way I want them via a method of my choosing; this app simply remembers that and restores it should motion stop long enough to have them turned off. Does setting your lights the way you want them and just letting this app keep them that way not work for your case? If you just want something that always turns lights on to a specific level every time motion is detected regardless of their previous state, most stock lighting apps can handle that. I wrote this specifically because I didn't want that. :slight_smile: (But then I guess you won't get dimming before off...)

The app works great and I definitely prefer it to the stock apps. Here's how my use case is slightly different. I light up a hallway with 3 dumb bulbs and zwave paddle switch, where there's motion. I like it at 35% after sunset and up until around 11pm. After that, I like to bring them up to only about 5-6%, just enough to light the way. Right now, my workaround is using rule machine to set the dimmer to 5% at 11pm. It would just be nice to have the option to specify what value you want the light brought up to :slight_smile:

Ok, so I do plan on introducing some sort of "night mode" feature where a level can can be set for that mode, then the next time when it's run in a non-night mode, it will restore either the previous non-night settings or a "reset" to a specified default (if it was last run in night mode; otherwise, it will keep doing what it always does). This will allow me to replace the webCoRE piston that currently rules my bathroom. :slight_smile: I don't think I want to turn this into a full, mode-based lighting app, but this one distinction is something that will help me and sounds like it might for you too.

EDIT: This is now out in v4.0. You can choose one or more "night modes," which will turn lights on to specified settings. Upon the next run in a "regular" mode, the previously saved settings from a non-night mode execution will be restored.

2 Likes

@bertabcd1234 Whould this app be helpful when trying to create a scenario like this. ?

Unfortunately, you'll Indeed need RM (or a custom app specific to that purpose)--mine can detect on or off buy doesn't respond differently to different existing dim levels.

Thanks for this great apps. A "kill switch" can be a contact sensor ? When the door closed , disable this apps , when the door change to open, this app activates . Thanks.

Not as-written, but I'll think about that for a future update. In the meantime, you can "fake it" by creating a virtual motion device whose status is controlled by the "real" contact sensor. I'm thinking @ogiewon's Virtual Motion with Switch driver plus a rule in Rule Machine that will turn on/off that virtual switch (which is also exposed as motion sensor) depending on the open/close state of the contact.

That's actually how I'm doing my "couch occupancy sensor" for my living room lighting automations. :slight_smile: (My couch has a pressure mat hooked up to a contact sensor that reports "closed" when the couch is occupied, which I have Rule Machine converting to an "active" motion sensor via this driver.)

1 Like

New release! Version 4.0 adds a "night mode" option:

  • Optionally, designate one or more modes as a "night mode" where lights will turn on with motion using special, specified settings; see below (compare to "regular" modes where lights will be turned on to previously saved settings)
  • Specify "night mode" level, color temperature, or color; if not already on, lights will turn on to these settings when motion detected in specfied mode(s), then off after timeout (no dimming first as in "regular" modes, under the assumption that these are generally dimmer settings to begin and it wouldn't do much good)
  • Optionally, choose one or more lights to ignore (not turn on) in night mode. By default, night mode settings will apply to all "normal" mode lights. I added this option because I only want one bulb to turn on at night, so I can add the others as "ignored" bulbs for night mode.
  • The next time motion is detected in a "normal" mode, level and color temperature will be restored as usual from the last captured settings when run in a "normal" mode (so pretty much the same as before; it won't save or restore the states from "night mode," and I added restoration of color temperature since it used to just restore level, which is insufficient if you change color/color temperature in night mode...won't restore full colors yet, but I could add that if there's demand).

Requires update to child app only (version 4.0). Parent app has not changed since initial release of version 3.0. Code links in post #1.

This is probably the most mode-releated capability I'll add to the app, but I am tempted to allow speciying one or two more "special" modes in case people want something different in other modes, like cool light in the morning and warm light in the evening (and something else at night, which you can now do)--or possibly an arbitrary number of "special" modes or settings per mode, but I can see that getting complicated fast with remembering which modes should restore saved settings and which should always just turn on to the "special"/specified settings (as the selected "night mode(s)" now do).

Enjoy, and let me know if you run into any problems!

1 Like

I had 2 issue :slight_smile: ,

  • when set " run between " times, the apps no working. If leave its blank , the apps working ?
    Lights%20on%20motion%20plus

-The light turn on at level 100, then dim to 50 before turning off. If I turn on " Remember states of individual lights before dimming … ", next time the light turn on at level 50, not level 100 ?

If you haven't updated to 4.1, I made some minor changes that may help with the second problem (saving the "dimmed" level instead of the "normal" one). For time, maybe try 11:59 instead of 12:00 to see if that helps? I haven't done a lot of testing with spanning multiple days, so it's possible midnight is an edge case I don't deal with properly yet. I'll look more into both problems. Thanks for the report!

1 Like

I have a question / feature request (actually two). I love the app so far. But I'm missing two things to be perfect (for me, that is :slight_smile:) :

  1. Don't turn off lights that were already on before motion was detected.
  2. Instead of a switch for "on" a dimmer level for "on".

Would that be possible? And can I help writing it (learning Groovy while doing it)?

I'm going to be honest: I have no interest in developing feature #1 since it does not represent how I use any of my lights. But if I get enough free time, I might look into it sometime. Feature #2 sound like what it already does: I know it presents a list of "switches" (or more specifically, things that implement the "Switch" capability), but that's because it needs the device to support on/off at a minimum. It should also show dimmers (specifically, "Switch Level" devices) because I'm fairly positive all dimmers/bulbs that implement this also implement Switch. If you have the "Remember states..." option enabled (as it is by default), then this app will turn those dimmers back on to their previous state when motion is detected again. If you want to always go on to a certain level regardless of what you had before, this app can't do this, and I can't think of a time when I'd want to, either (except in specific modes, which is why the "night mode" feature was added), so it's also unlikely. :slight_smile: (The main reason I wrote this app was because stock apps like another platform's Smart Lighting app would blindly turn on all selected lights even if one was already on and that's all you wanted; I added the "dim before off" warning to emulate what the Hue network eventually became capable of doing because it sounded neat. Part of both of these features is remembering the "real" previous state of the lights, since a simple "on" will just put them on back to the bulb's "dimmed" level.)

The code is open-source and you are certainly welcome to take a crack at either of these. The first would probably be pretty simple (store a list of bulbs that were already on when motion was detected, then check that same list before turning off--if the option to do so, which I'd definitely not enable by default, were enabled). I'm honestly not exactly sure what you want with the second, but it sounds either possible already or something unlikely to fit in with the original goals of the app (if you want the bulbs to come on to a certain level, set them that way--it will remember :slight_smile: ).

I think I will have to learn Groovy then. To explain my 2 desires a little more:

  1. I have a scene running with a couple of lights in it. One of those lights I want to up the brightness when I move inside that area, when I move away I want it to go back to the dim level it was.
  2. I want to control the dim level when triggered because of what I explained above, bit also because my Philips hue lights are in different scenes and it is not desired to have them go on on the level they last had.

New to HE and loving it, playing around with using motion detection to turn lights on in night mode, instead of turning the light off completely after the off timer, is there a way to just dim it instead of turning completely off?

You could modify my code to do that, but my goal is to turn my lights off (dimming is the part in this app that's optional), so I'm unlikely to do that myself. You could certainly accomplish what you want using Rule Machine, if you're comfortable using that.

I have made a small update to the child app (version 4.2), which adds a second option for "night mode." Instead of setting lights to specific settings, you can now choose a Hue Bridge scene instead if you're using CoCoHue and have a device created for that scene. (Since a Hue scene cannot be "turned off," you will need to have the same lights/groups selected elsewhere in the app for "normal" on/off actions. I'm not sure why you wouldn't anyway, but I guess I should mention it. This group also needs to be considered "on" if any member lights are on, which CoCoHue groups do. Mileage may vary with others.)

Note for upgrading: if you're using night-mode settings, go into the app and in the "Night Mode" section, choose the "Turn lights on to specific settings" for the new "In night mode..." option. This will make it work as it did before. (If you didn't use night-mode settings, you do not need to change anything.) Or you could be like me and use this as an opportunity to activate a Hue Bridge scene instead. :slight_smile:

3 Likes

Hi.

A great app! Thank you soo much!

In the standard app that is included, one can choose color temperature and level when motion is detected, if you select by mode. Is there a way to select what level is to be used, when motion is detected in the different modes? I have the bedroom using Motion Lighning app and have different levels for different modes. Is that a huge task to implement? You are on the way there by the night mode selection, so it would be great to be able to do this for more than one mode. Just a wet dream, since I do not code myselves. Maybe the ambassadors can provide you with the source code for the included included standard app that comes with the HE? Then it should be easy peasy, I guess... hihi
Here is an excample of the bedroom floor lamp i use in the included app:

RogerThat
Oslo, Norway

Unfortunately, no. Right now, "night mode" (which can really be any mode or modes you choose) is the only "special" mode. The idea behind my app was for the app to remember what light settings you used the last time the app was run (in a mode where it would turn on the lights, except any "night modes") and then restore them to that state. Even with night mode, it doesn't remember your settings there--it just always turns them on to what you specify. The rest of the time, if it turns the lights on at all, it goes to what you had them turned on to last. I'm not sure how different modes would fit in here (would it remember your settings per mode? what if mode changes while the lights are on? should it not remember the "new" settings if they're from the "old" mode? or should it change them with mode if they're on? what if you manually changed them at some point? this gets complicated fast).

I may consider adding an option to specify one or two more "special" modes, with the idea being that it might be used for some sort of "early morning" or "late evening"-type mode. You also might be able to combine my app with a rule: if X light turns on in Y mode and this is the first time it turned on in that mode today, set it to Z color temperature. My app should be able to handle the rest if you take care of changing the color temperature based on time/mode/whatever some other way when the lights turn on the first time under those conditions (and you can take care of the remaining logic, too--e.g., what if the lights are already on then?). No guarantees, but I'll consider the idea. :slight_smile:

Thanks for the feedback!

They have provided a few example drivers (and possibly an app?) for the community, but the majority of the source is closed. This is definitely a dream. :slight_smile:

1 Like

I wish I had searched for this app before spending hours setting up a rule that would do the same thing!!! I am quite glad I found it though! It works great and is so easy to setup! Great work!

Feature Request: Would it be possible to set an option that, like "Hubitat Simple Lighting" would only turn the lamp off? Alternatively, some lamps could be selected that would only turn off?

I really love how it dims before turning off, and have a lot of my lamps setup in the "Hubitat Simple Lighting" to only turn off. I think if this app could do this, I would migrate most of them to it.

Really great app! Thanks!

It might work that way if you just select no modes, but that might make it work in all modes. I honestly don't remember how I wrote that section of the code because I never intended it to be used in that way. I do know it would work if you chose a mode you don't really use, which is what I'm doing in one "off only" room of mine with "Away" mode, which I don't use but still kept (for inside lights, I guess this would be pretty harmless for most people even if you did use it).

I certainly understand this need and have plans to re-do big parts of the app and will definitely include something like this in a much cleaner fashion if I do. The other alternative would be to use the "don't turn on lights if this switch is on" option and just create an always-on virtual switch you can use for this or other instances where you only want the automatic off. Again, something I understand now but didn't need in the apartment I originally wrote this app for. :slight_smile: