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:
     *
     *      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: "Bedroom Night Lights",
        namespace: "",
        author: "Craig Lyons",
        description: "Used to control the bedroom nightlights.",
        category: "My Apps",
        iconUrl: "http://www.philips.co.jp/shared/assets/jp/SmallParagraphImage/ConsumerCare/hue_80x70.jpg",
        iconX2Url: "http://www.philips.co.jp/shared/assets/jp/SmallParagraphImage/ConsumerCare/hue_80x70.jpg",
        iconX3Url: "http://www.philips.co.jp/shared/assets/jp/SmallParagraphImage/ConsumerCare/hue_80x70.jpg")
    
    
    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",
    					"White",
    					"Daylight",
    					"Warm White",
    					"Red","Green","Blue","Yellow","Orange","Purple","Pink"]
    				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}"
    
    	initialize()
    }
    
    def updated() {
    	log.debug "Updated with settings: ${settings}"
    
    	unsubscribe()
    	initialize()
    }
    
    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
    				break;
    			case "Daylight":
    				hueColor = 53
    				saturation = 91
    				break;
    			case "Soft White":
    				hueColor = 23
    				saturation = 56
    				break;
    			case "Warm White":
    				hueColor = 20
    				saturation = 80 //83
    				break;
    	 	 	case "Blue":
    				hueColor = 70
    				break;
    			case "Green":
    				hueColor = 39
    				break;
    			case "Yellow":
    				hueColor = 25
    				break;
    			case "Orange":
    				hueColor = 10
    				break;
    			case "Purple":
    				hueColor = 75
    				break;
    			case "Pink":
    				hueColor = 83
    				break;
    			case "Red":
    				hueColor = 100
    				break;
    	}
    
    	if (color != "On - Custom Color")
        {
            def newValue = [hue: hueColor, saturation: saturation, level: lightLevel as Integer ?: 100]
            hues*.setColor(newValue)
    		log.debug "new value = $newValue"
        }
        else
        {
        	hues*.on()
        }
    
    	state.motionStoppedAt = -99    
    }
    else if (evt.value == "inactive")
    {
    	log.trace "inactive"
        //runIn(60, turnOfflights)
        state.motionStoppedAt = now()
        turnOfflights()
    }
    
    }
    
    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)
        {
        	hues*.off()
        }
        else 
        {
        	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.

Craig,

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.