Lights on Motion SmartApp?


(Brian Smith) #1

OK, I’m playing the role of Stupid today…

Where is the SmartApp for turning on a dimmer when motion is detected? I don’t see one under “More” in the ST App. I thought it was called Lights Follow Me or something like that.

I’m not using the standard motion in Lights & Switches because of the limitation of not having multiple versions of it. See my other post if interested…but not necessary for this post. :smile:


(Brian Smith) #2

Anyone? Bueller? Bueller?


(Korban Hadley) #3

After I waited about 10 min (small exaggeration) for my ST app to load I had to look myself. It’s not under More. It is under Lighting. I am however, not aware of one that is designed for just dimmers. Are you looking for one that sets the dimmer to a certain level?


(Bruce) #4

It’s in Lights & Switches: Turn on when there is motion. That allows you to set the dimmer level. Remember, Lights & Switches are just shortcuts (little apps). You can have as many of them as you need, including multiple ones that refer to the same devices.


(Brian Smith) #5

I can’t use the one in Lights and Switches because it can only be loaded once. I need to load it several times for different house modes. The one under Actions…Lighting is the same thing as in the lighting group. This was the crux of my other long-form post about the interface issue.


(Bruce) #6

You can have as many of them (shortcuts) as you want. They just have to have different names. When it says, “Living Room already configured”, that refers to the shortcut called “Living Room”, not the devices.

Or, I have an app that does it automatically for 3 modes and 3 levels. Send me a PM if you want that…


(Brian Smith) #7

Yep, I thought about that as well. However, that seems like it would unnecessarily clutter my interface…an interface that does not sort the same way every time you open it! So, two bad UI issues are deterring me from that.


(Bruce) #8

You need to get over worrying about the mobile app as anything more than a configuration tool. If you need customized UI, just use ActiON. The mobile app is lousy as a UI tool for controlling ST. But, it’s essential for configuring things.


(Brian Smith) #9

Oh, I agree and I’ll probably do it. (I’ll go find my big boy pants) However, even if you treat it just as a configuration tool, the unnecessary clutter is still not good and causes confusion. Thankfully, I generally have really good naming conventions that help identify and group things properly. Of course, the grouping doesn’t work because that part of the UI doesn’t actually work…and I’m still confused why they don’t just add a sort order of alphabetical and be done with it for now until some sort of re-write.


(Bruce) #10

When you go into Lights & Switches, just hit the gear icon at the top. That will give you an alphabetized list of all of the shortcuts. Or, swipe left in Lights & Switches and you will get an alphabetized list with their current state.


(Nico) #11

@brianlees @bravenel
There is a SmartApp called “Light Turn On Motion” that turn on light when there’s a motion, and turn it off again after motion stopped.

But, I can’t find the code from template at IDE.
Where is it ?

I want to create custom app start from that app, maybe any of you can help to find that code
Thanks


(Brian Smith) #12

I remember it being there in the past. Not sure why it isn’t there now. I could have thought I saw it when I was having a few glasses of wine!

Let me tag @Jim. Although this is not really documentation…it sort of is since it is a “core smartapp.” (kinda making that up, but it sounds about right!) Sorry, Jim. Tag, your it. :smile:


(Jim Anderson) #13

It’s called “Light Follows Me”. Let me know if you can’t find it in the IDE - I think it should be there…


(Nico) #14

Thanks @Jim
at “light turn on motion” there’s a dimming level, at “Light Follows Me” there’s no dimming choice

I’m not good at programming, so I need the exact example for editing the custom app that I want :smile:


(Bruce) #15

Here is the code for a basic “Turn on with motion” app. It doesn’t turn them back off after x minutes, but you can use “Turn off when there is no motion” from Lights & Switches to do that. Maybe this will get you going:

/**
 *  Turn on with Motion
 *
 *  Copyright 2015 Bruce Ravenel
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
    name: "Turn on with Motion",
    namespace: "bravenel",
    author: "Bruce Ravenel",
    description: "Turn on dimmers to preset level",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")


preferences {
	section("Turn on these dimmers...") {
		input "dimmer1", "capability.switchLevel", title: "Which?", multiple: true, required: true
	}
    
    section("To this dimmer level...") {
    	input "dimLevel", "number", title: "What level?", multiple: false, required: true, description: "0 - 99"
    }
    
    section("When there is motion here...") {
    	input "motions", "capability.motionSensor", title: "Which?", multiple: true, required: true
    }
}

def installed() {
//	log.debug "Installed with settings: ${settings}"

	initialize()
}

def updated() {
//	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(motions, "motion.active", motionOnHandler)
}

def motionOnHandler(evt) {
    dimmer1.setLevel(dimLevel)
}

(Nico) #16

Thanks @bravenel
the “Light Follows Me” is almost perfect for me. I just need to add dimming function to that app.
I saw your app using capability.switch level, is that only what I need to add the dimming capability ?

One scenario that I want is, when there’s a motion my Hue bulb is set to 100% brightness, and when motion is stopped it will set to 50% brightness for example.

I already install “Light Turn On Motion” on my ST, that app is can set the dimming level of my light, just need to change the turn off command to reduce the brightness.
But that app is not available at template.

Waiting Jim to find it for me, hehe :smile:


(Bruce) #17

This can be easily added to the app. Add this:

section("When motion stops, set to this level") {
    input "dimLevelOff", "number", title: "What level?", multiple: false, required: true
}

subscribe(motions,"motion.inactive",motionOffHandler)

def motionOffHandler(evt) {
    dimmer1.setLevel(dimLevelOff)
}

(Dave N) #18

Have a look at Light Director, you have the dimming built in.


(Nico) #19

Thanks again @bravenel , let me try it

I can’t find ‘Light Director’ from template @daven , is it there with different name ?

Update :
Now I unable to create app that I want using setLevel command, setLevel is working to set my Hue brightness, but I got error message log

errorjava.lang.IllegalArgumentException: Command ‘setLevel’ is not supported. Supported commands: [on, off, poll, configure, refresh, reset] @ line 46


(Nico) #20

How to add “more option” section on smartapp ?

to chose time, day and mode settings