Skip to content

Commit

Permalink
Pulled updates from current running code
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Priddy committed Jun 11, 2015
1 parent af41dd2 commit 2b518fb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 979 deletions.
21 changes: 20 additions & 1 deletion Hue SmartApps and Devices/zp_hue_bulb_device.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def off(transitiontime)
}

def poll() {
parent.poll(this)
parent.poll()
}

def nextLevel() {
Expand All @@ -139,10 +139,16 @@ def nextLevel() {
def setLevel(percent)
{
def transitiontime = 4
if(device.latestValue("level") as Integer == 0)
(
transitiontime = 0
)

log.debug "Executing 'setLevel'"
parent.setLevel(this, percent, transitiontime)
sendEvent(name: "level", value: percent)
sendEvent(name: "transitiontime", value: transitiontime)
sendEvent(name: "switch", value: "on")

}
def setLevel(percent, transitiontime)
Expand Down Expand Up @@ -188,6 +194,7 @@ def setHue(percent, transitiontime)

def setColor(value) {
log.debug "setColor: ${value}"
def isOff = false

// TODO: convert hue and saturation to hex and just send a color event
if(value.transitiontime)
Expand All @@ -213,12 +220,24 @@ def setColor(value) {
{
sendEvent(name: "level", value: value.level)
}
else
{
// sendEvent(name: "level", value: 1)
value.level = 1
value.transitiontime = 0
isOff = true
}
if (value.switch)
{
sendEvent(name: "switch", value: value.switch)
}

parent.setColor(this, value)
if (isOff)
{
parent.off(this, 0)
}

}

def setAdjustedColor(value) {
Expand Down
21 changes: 16 additions & 5 deletions Hue SmartApps and Devices/zp_hue_group_device.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ metadata {
valueTile("transitiontime", "device.transitiontime", inactiveLabel: false, decoration: "flat") {
state "transitiontime", label: 'Transitiontime ${currentValue} '
}
valueTile("color", "device.color", inactiveLabel: false, decoration: "flat") {
state "color", label: 'color ${currentValue} '
}



main(["switch"])
details(["switch", "levelSliderControl", "rgbSelector", "refresh","transitiontime"])
details(["switch", "levelSliderControl", "rgbSelector", "refresh","transitiontime","color","saturation","level","hue"])

}

Expand Down Expand Up @@ -121,7 +126,7 @@ def off(transitiontime)
}

def poll() {
parent.poll(this)
parent.poll()
}

def nextLevel() {
Expand Down Expand Up @@ -188,7 +193,7 @@ def setHue(percent, transitiontime)
def setColor(value) {
log.debug "setColor: ${value}"

// TODO: convert hue and saturation to hex and just send a color event

if(value.transitiontime)
{
sendEvent(name: "transitiontime", value: value.transitiontime)
Expand All @@ -201,13 +206,18 @@ def setColor(value) {
if (value.hex)
{
sendEvent(name: "color", value: value.hex)

}
else if (value.hue && value.saturation)
{
def hex = colorUtil.hslToHex(value.hue, value.saturation)
sendEvent(name: "color", value: hex)
}

if (value.hue && value.saturation)
{
sendEvent(name: "saturation", value: value.saturation)
sendEvent(name: "hue", value: value.hue)
}
if (value.level)
{
sendEvent(name: "level", value: value.level)
Expand All @@ -233,7 +243,7 @@ def save() {

def refresh() {
log.debug "Executing 'refresh'"
parent.poll(this)
parent.poll()
}

def adjustOutgoingHue(percent) {
Expand All @@ -257,3 +267,4 @@ def adjustOutgoingHue(percent) {




Loading

0 comments on commit 2b518fb

Please sign in to comment.