# Motion Lighting

**URL:** <https://community.smartthings.com/t/motion-lighting/24064>\
**Category:** Community Created SmartApps\
**Tags:** smartapp\_lighting\
**Created:** [September 26, 2015, 2:52pm UTC](https://community.smartthings.com/t/motion-lighting/24064 "2015-09-26T14:52:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![bravenel](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/bravenel/32/13223_2.png) [@bravenel](https://community.smartthings.com/u/bravenel)\
**Post date:** [September 26, 2015, 2:52pm UTC](https://community.smartthings.com/t/motion-lighting/24064/1 "2015-09-26T14:52:11Z")

</div>

For those who have the need for lights controlled by motion sensors, who want different brightness for different modes, and want it to work now instead of waiting for ST to debug Smart Lights, “Motion Lighting” performs these functions (and works!).

> <https://github.com/bravenel/SmartThings/blob/master/Motion%20Lighting>

---

<div class="post-metadata">

**Author:** ![patrija](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@patrija](https://community.smartthings.com/u/patrija)\
**Post date:** [September 26, 2015, 4:16pm UTC](https://community.smartthings.com/t/motion-lighting/24064/2 "2015-09-26T16:16:29Z")

</div>

Just installed Motion Lighting. It seems to be closer to what I describe but still sets a single % for all of the “child” dimmer switches. Or did I miss something?

Also, a small bug - picking a Mode is required. It does not allow selection of “All Modes”

Thanks!

---

<div class="post-metadata">

**Author:** ![bravenel](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/bravenel/32/13223_2.png) [@bravenel](https://community.smartthings.com/u/bravenel)\
**Post date:** [September 26, 2015, 4:21pm UTC](https://community.smartthings.com/t/motion-lighting/24064/3 "2015-09-26T16:21:10Z")

</div>

> [@patrija](#):
>
> single % for all of the “child”

You are correct. This too only supports a single dimmer level between the master and slave dimmers for a given mode for a single instance of the app. To get more dimmer levels for the same mode, you would need more than one instance. It actually used to support multiple dimmer levels, but I found it very cumbersome. I use one instance of this for each lighting area, of which some rooms have more than one. But, for my lighting, I didn’t need multiple dimmer levels within one lighting area.

Edited: About the mode selections: If you want a single dimmer level for all modes, simply select you main mode and set its level. Other modes will be disregarded, and use the same level.

---

<div class="post-metadata">

**Author:** ![patrija](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@patrija](https://community.smartthings.com/u/patrija)\
**Post date:** [September 26, 2015, 4:30pm UTC](https://community.smartthings.com/t/motion-lighting/24064/4 "2015-09-26T16:30:47Z")

</div>

Thanks for the quick reply.

When I leave the Mode Option “blank” … which is click to set defaulted to “All Modes” … the app throws an error when I click next. It seems to require that a mode (or modes) are selected. May be by design

---

<div class="post-metadata">

**Author:** ![bravenel](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/bravenel/32/13223_2.png) [@bravenel](https://community.smartthings.com/u/bravenel)\
**Post date:** [September 26, 2015, 4:33pm UTC](https://community.smartthings.com/t/motion-lighting/24064/5 "2015-09-26T16:33:47Z")

</div>

Yes, you must specify the modes you want to set levels for, and there must be at least one. If you only pick one mode, the levels will be the same for all modes. Any mode not selected is simply ignored when it comes to changing the dimmer levels. Just pick your main mode if you want the lights to stay at one level. The app will automatically select the mode you are in when you install it as the initial default mode, but you can select as many as you want.

---

<div class="post-metadata">

**Author:** ![pd\_](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@pd\_](https://community.smartthings.com/u/pd_)\
**Post date:** [September 26, 2015, 5:23pm UTC](https://community.smartthings.com/t/motion-lighting/24064/6 "2015-09-26T17:23:12Z")

</div>

superState is your friend

---

<div class="post-metadata">

**Author:** ![patrija](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@patrija](https://community.smartthings.com/u/patrija)\
**Post date:** [September 26, 2015, 5:55pm UTC](https://community.smartthings.com/t/motion-lighting/24064/7 "2015-09-26T17:55:43Z")

</div>

Trying that next thanks!

---

<div class="post-metadata">

**Author:** ![patrija](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@patrija](https://community.smartthings.com/u/patrija)\
**Post date:** [September 27, 2015, 4:02pm UTC](https://community.smartthings.com/t/motion-lighting/24064/8 "2015-09-27T16:02:45Z")

</div>

Looking up superstate … do you mean the :“beta v1.1”?

---

<div class="post-metadata">

**Author:** ![pd\_](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@pd\_](https://community.smartthings.com/u/pd_)\
**Post date:** [September 27, 2015, 4:37pm UTC](https://community.smartthings.com/t/motion-lighting/24064/9 "2015-09-27T16:37:19Z")

</div>

Correct. Follow the instructions on GitHub, and you’ll be set.

---

<div class="post-metadata">

**Author:** ![av8rdude](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/av8rdude/32/82750_2.png) [@av8rdude](https://community.smartthings.com/u/av8rdude)\
**Post date:** [September 27, 2015, 8:07pm UTC](https://community.smartthings.com/t/motion-lighting/24064/10 "2015-09-27T20:07:55Z")

</div>

I would love to have a version of your app that does not use dimmers. My kitchen lighting is on zwave switches. I tried to modify your code but the IDE seems to be on the blink at the moment for creating new apps.  
Cheers,  
Scott

---

<div class="post-metadata">

**Author:** ![bravenel](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/bravenel/32/13223_2.png) [@bravenel](https://community.smartthings.com/u/bravenel)\
**Post date:** [September 27, 2015, 9:06pm UTC](https://community.smartthings.com/t/motion-lighting/24064/11 "2015-09-27T21:06:26Z")

</div>

> [@av8rdude](#):
>
> a version of your app that does not use dimmers

What is it that you want? The motion control? Obviously the dimmer levels per mode is irrelevant. If it’s just switches activated by motion, for on and off, that is totally doable with Smart Lights.

---

<div class="post-metadata">

**Author:** ![av8rdude](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/av8rdude/32/82750_2.png) [@av8rdude](https://community.smartthings.com/u/av8rdude)\
**Post date:** [September 27, 2015, 9:16pm UTC](https://community.smartthings.com/t/motion-lighting/24064/12 "2015-09-27T21:16:44Z")

</div>

Smart lights has a bug. If you select turn off 2 minutes after motion stops and there is a motion off event it will turn the lights off after this initial motion off event. It does not reset the timer if another motion event occurs after motion stops during this 2 minute timer.  
I’ve discussed this at length in some other threads.  
Before Smart Lighting I had my kitchen lighting setup to turn off X minutes after the motion stops. It worked perfectly and never turned off while motion was present.

---

<div class="post-metadata">

**Author:** ![bravenel](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/bravenel/32/13223_2.png) [@bravenel](https://community.smartthings.com/u/bravenel)\
**Post date:** [September 27, 2015, 9:30pm UTC](https://community.smartthings.com/t/motion-lighting/24064/13 "2015-09-27T21:30:44Z")

</div>

Got it. I’ve heard about that bug. I wrote a little app to handle “Turn off after motion stops” that does that function (reliably – 😀). Just use Smart Lights to turn things on the way you want, and use this app to turn them off after motion stops (instead of Smart Lights doing it). That should get you around the bug until they fix it.

Go to this thread:

> [@Turn off after motion stops](https://community.smartthings.com/t/turn-off-after-motion-stops/22847):
>
> Smart Lights has a functionality missing that many people use, a function that was available in Lights & Switches V1. The missing function is to specify how many minutes after motion stops to turn something off. This functionality is there if you use Smart Lights to turn on a light with motion, and then turn it off when motion stops. But if you only want to turn something off some number of minutes after motion stops, where it was turned on by some other means, that functionality is missing. I’m sure that SmartThings will fix this omission soon. EDITED: ST has fixed this omission in mobile app V2.0.4. Smart Lighting can now do this function. As of 10/24/15. However, this is only true for hub V1 users. It is still not available for hub V2 In the meantime, this app provides that f…

---

<div class="post-metadata">

**Author:** ![av8rdude](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/av8rdude/32/82750_2.png) [@av8rdude](https://community.smartthings.com/u/av8rdude)\
**Post date:** [September 28, 2015, 12:34am UTC](https://community.smartthings.com/t/motion-lighting/24064/14 "2015-09-28T00:34:40Z")

</div>

Thanks Bruce! That fixed my undercabinet lighting.  
Cheers,  
Scott

---

<div class="post-metadata">

**Author:** ![jamesc](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jamesc/32/20124_2.png) [@jamesc](https://community.smartthings.com/u/jamesc)\
**Post date:** [November 9, 2015, 10:17pm UTC](https://community.smartthings.com/t/motion-lighting/24064/15 "2015-11-09T22:17:53Z")

</div>

Hi @bravenel – just starting using this code and it seems to be working great, one option that would be really helpful though would be to have the ability to set philips hue color when turning on a set of lights. The dimmer option works great, how easy would it be to implement the color option also?

---

<div class="post-metadata">

**Author:** ![bravenel](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/bravenel/32/13223_2.png) [@bravenel](https://community.smartthings.com/u/bravenel)\
**Post date:** [November 9, 2015, 11:15pm UTC](https://community.smartthings.com/t/motion-lighting/24064/16 "2015-11-09T23:15:08Z")

</div>

James, I don’t have any Hue bulbs, so I haven’t messed with color AT ALL. It should be possible to extend the app to use color, but I haven’t looked at it. This is not on my list of things to do right now. Maybe someday…

---

<div class="post-metadata">

**Author:** ![jamesc](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jamesc/32/20124_2.png) [@jamesc](https://community.smartthings.com/u/jamesc)\
**Post date:** [November 10, 2015, 8:31am UTC](https://community.smartthings.com/t/motion-lighting/24064/17 "2015-11-10T08:31:35Z")

</div>

I had a little play around with the code and actually managed to get it working.

For anyone who may want to do this you just need to do the following:

Find def switchesOn() and within that replace

```
master.setLevel(state.dimLevel)
slaves?.setLevel(state.dimLevel)

```

with

```
master.setColor([hue: 23, saturation: 56, level: state.dimLevel])
slaves?.setColor([hue: 23, saturation: 56, level: state.dimLevel])

```

This is obviously a very basic change (with a hardcoded color) and will need additional tweaking to be able to select a color from the app.

---

<div class="post-metadata">

**Author:** ![michaelahess](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/michaelahess/32/27733_2.png) [@michaelahess](https://community.smartthings.com/u/michaelahess)\
**Post date:** [December 29, 2015, 10:38pm UTC](https://community.smartthings.com/t/motion-lighting/24064/18 "2015-12-29T22:38:59Z")

</div>

I’m trying this app in place of RE because of delay issues. I can get it to work great with my GE Link bulbs but my Cree’s won’t dim after turning on the first time. The first time they do go to the correct value. Using Wackware GE Link Bulb as the device type (same as on the working GE bulbs) tried the generic Dimmer Switch as well as a Cree device type knowing it wouldn’t work, it didn’t. Any thoughts on what device type to use for the virtual switch?

---

<div class="post-metadata">

**Author:** ![bravenel](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/bravenel/32/13223_2.png) [@bravenel](https://community.smartthings.com/u/bravenel)\
**Post date:** [December 30, 2015, 12:48am UTC](https://community.smartthings.com/t/motion-lighting/24064/19 "2015-12-30T00:48:45Z")

</div>

I don’t know what RE is, or what delay issues you are referring to. I’m using Motion Lighting with Cree bulbs, using the first Device Type published by ST for the Cree bulbs, called “My Cree Bulb beta”. That works fine for me, and I’m able to control my Crees just like any other dimmer I have.

Which virtual switch are you asking about?

---

<div class="post-metadata">

**Author:** ![michaelahess](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/michaelahess/32/27733_2.png) [@michaelahess](https://community.smartthings.com/u/michaelahess)\
**Post date:** [December 30, 2015, 2:03am UTC](https://community.smartthings.com/t/motion-lighting/24064/20 "2015-12-30T02:03:48Z")

</div>

Ha, sorry was thinking rule machine while reading about an engine, brain short circuit. Rule machine takes between two and three seconds to bring a light on from a motion sensor. Takes half that time when processed local.

My setup is two cree or ge smart bulbs in a single fixture. Since ST doesn’t do groups that I’ve found, I have a dummy switch that controls both real bulbs, hence using RM, Dim with Me, or Motion Lighting. The ge bulbs work with motion lighting and the dummy switch when device type of the dummy is the wackware ge link bulb.

I’m guessing I need a virtual device type similar to that but with the correct Cree coding.

Obviously I could just tie one bulb to the other in motion lighting but that would break some of my rules that use each light brightness individually from one another.

[Next page](https://community.smartthings.com/t/motion-lighting/24064.md?page=2)
