How To: Set Custom Color and Brightness of Hue Bulbs

(Joseph Fattizzi) #1

Does anyone know how to set and recall custom colors and brightness levels for a hue bulb or set of hue bulbs?

(Justin) #2

I started a thread on this. Sorry for the crude pasting but I’m on a tablet.

Anyway… there are various methods to control lights (ie. switch.on() or ). For Hue bulbs you have to change the capability of your device from a switch to capability.colorcontrol.

Then you can define a color simply by setting hue, sat and level

Continuing the discussion from Random Hue Color within a smart app:

Ok. I made some changes to my overall app which is simple. I will test in real life, but in the simulation it appears not to change color. My concern is that this is device related NOT my program.

I have the OSRAM 73661 Smart Connected Lighting LED Flexible Strip. The device is installed properly and I can change colors directly by using the device within ST.

Here is my code:

 *  Copyright 2015 SmartThings
 *  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.
 *  Turn It On When It Opens
 *  Author: SmartThings
    name: "Matthew's Under Bed Light",
    namespace: "JDogg",
    author: "JDogg",
    description: "Turn something on when an open/close sensor opens.",
    category: "Convenience",
    iconUrl: "",
    iconX2Url: ""

preferences {
	section("When the door opens..."){
		input "contact1", "capability.contactSensor", title: "Where?"
	section("Turn on a light..."){
		input "switches", "capability.colorControl", multiple: false

def init()
	subscribe(contact1, "", contactOpenHandler)
    subscribe(contact1, "contact.closed", contactClosedHandler)


def updated()
	subscribe(contact1, "", contactOpenHandler)
    subscribe(contact1, "contact.closed", contactClosedHandler)

def contactOpenHandler(evt) {
	log.debug "$evt.value: $evt, $settings"
	log.trace "Turning on switches: $switches"
	//Get Random Number
	def ranNum = new Random().nextInt(65000) + 1
    def ranSat = new Random().nextInt(99) + 1
	log.debug "Color is $ranNum and Saturation is $ranSat"

def contactClosedHandler(evt) {
	log.debug "$evt.value: $evt, $settings"
    log.trace "Turning off switches: $switches"[delay: 300 * 1000])