Modes and smart night light

Ok I just recently got smart things about 2 weeks ago and all I have are the smart motion sensors and hue lights, I have the smart night light which turns on the lights when its dark and there is movement, and off when its light and no movement… thats in home and away mode. Now every time I put it in night mode and when I wake up and say good morning the lights turn on because there is motion, but obviously its not supposed too because its daytime, to fix it I always have to go to the smart night light and click “done” again. If I have to do this everyday when I wake up Im just gonna return this because this is ridiculous.

This sounds like a bug in the app. If I were you I’d use the native apps within the dashboard instead of installing an app. I find these handle the situation far better.

Here’s my app that I created that I find works amazing for this (next post):

     *  Bedroom Night Lights
     *  Copyright 2014 Craig Lyons
     *  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:
     *  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.
        name: "Bedroom Night Lights",
        namespace: "",
        author: "Craig Lyons",
        description: "Used to control the bedroom nightlights.",
        category: "My Apps",
        iconUrl: "",
        iconX2Url: "",
        iconX3Url: "")
    preferences {
    	section("Control these bulbs...") {
    			input "hues", "capability.colorControl", title: "Which Hue Bulbs?", required:true, multiple:true
    		section("Choose light effects...")
    				input "color", "enum", title: "Hue Color?", required: false, multiple:false, options: [
    					"On - Custom Color",
                        "Soft White",
    					"Warm White",
    				input "lightLevel", "enum", title: "Light Level?", required: true, options: ["10","20","30","40","50","60","70","80","90","100"]
        section("Motion") {
    		input "motionDectors", "capability.motionSensor", title: "Motion"
    def installed() {
    	log.debug "Installed with settings: ${settings}"
    def updated() {
    	log.debug "Updated with settings: ${settings}"
    def initialize() {
    	subscribe(motionDectors, "motion", motionHandler)
    def motionHandler(evt)
    log.trace "evt: ${evt}"
    if (evt.value == "active")
    	log.trace "active"
        def hueColor = 70
    	def saturation = 100
    	switch(color) {
    			case "White":
    				hueColor = 52
    				saturation = 19
    			case "Daylight":
    				hueColor = 53
    				saturation = 91
    			case "Soft White":
    				hueColor = 23
    				saturation = 56
    			case "Warm White":
    				hueColor = 20
    				saturation = 80 //83
    	 	 	case "Blue":
    				hueColor = 70
    			case "Green":
    				hueColor = 39
    			case "Yellow":
    				hueColor = 25
    			case "Orange":
    				hueColor = 10
    			case "Purple":
    				hueColor = 75
    			case "Pink":
    				hueColor = 83
    			case "Red":
    				hueColor = 100
    	if (color != "On - Custom Color")
            def newValue = [hue: hueColor, saturation: saturation, level: lightLevel as Integer ?: 100]
    		log.debug "new value = $newValue"
    	state.motionStoppedAt = -99    
    else if (evt.value == "inactive")
    	log.trace "inactive"
        //runIn(60, turnOfflights)
        state.motionStoppedAt = now()
    def turnOfflights() {
        def elapsed = now() - state.motionStoppedAt
        def threshold = (60000 * 5) 
        log.trace "elapsed: ${elapsed}"
        log.trace "threshold: ${threshold}"
        if (elapsed >= threshold && state.motionStoppedAt != -99)
        	runIn(60, turnOfflights)
1 Like

Hey Craig thanks for letting me use your app, Im new to this I copied it and published the app but I don’t know how to get it on my app on my iPhone?

No Problem - we all started somewhere!

Once you have the App saved and published (for me). Click the “+” at the bottom of the dashboard within your mobile app. From there scroll right until the last option which should be “My Apps”. There you should see this new app and install it like any other app.

FYI - “Custom - On” just turns the hue on and off and leaves the exact colors / brightness that were set before it was turned off last time. Nice if you want an exact look, otherwise the pre-set colors pretty well.

Ok I got your app working but unfortunately this won’t work for me because I need the lights to turn when theres motion and its dark outside.

@pin0yizm - I personally turn on lights in my bed room unless we’ve gone to bed. I use modes to tell the lights to turn on or not.

Do you have a device that tells you if it’s dark or not or do you want to base it off of sunset?

Works just fine for me. I would try to reinstall app and enter zip code to make sure that day and night are correct.


I installed your code and use it for a late night nightlight when I stop home from work. Works great and I appreciate it! But what would make it even better for me, is to allow multiple motion doctors to be selected. I have one covering the entrance stairs and that’s what I have selected now. My second sensor covers the interior stairs and that would allow for those late night refrigerator runs.