Compare commits

..

1 Commits

Author SHA1 Message Date
Donald C. Kirker
d1a69d9344 MSA-877: Spruce deployment with fixes (going to attempt to get Nate's original pull request updated with this code and use that; this is fallback).
Revert value used for testing.
Update with bugfix from Plaid Systems.
2016-02-11 19:47:51 -08:00
4 changed files with 16 additions and 154 deletions

View File

@@ -80,12 +80,19 @@ def parse(String description) {
if (cmd) {
result = zwaveEvent(cmd)
}
log.debug "Parsed ${description.inspect()} to ${result.inspect()}"
// log.debug "Parsed ${description.inspect()} to ${result.inspect()}"
return result
}
def zwaveEvent(physicalgraph.zwave.commands.multiinstancev1.MultiInstanceCmdEncap cmd) {
def encapsulated = cmd.encapsulatedCommand([0x31: 1, 0x84: 2, 0x60: 1, 0x85: 1, 0x70: 1])
def encapsulated = null
if (cmd.respondsTo("encapsulatedCommand")) {
encapsulated = cmd.encapsulatedCommand()
} else {
def hex1 = { n -> String.format("%02X", n) }
def sorry = "command: ${hex1(cmd.commandClass)}${hex1(cmd.command)}, payload: " + cmd.parameter.collect{ hex1(it) }.join(" ")
encapsulated = zwave.parse(sorry, [0x31: 1, 0x84: 2, 0x60: 1, 0x85: 1, 0x70: 1])
}
return encapsulated ? zwaveEvent(encapsulated) : null
}

View File

@@ -487,6 +487,11 @@ def enrollResponse() {
}
private Map parseAxis(String description) {
def hexToSignedInt = { hexVal ->
def unsignedVal = hexToInt(hexVal)
unsignedVal > 32767 ? unsignedVal - 65536 : unsignedVal
}
def z = hexToSignedInt(description[0..3])
def y = hexToSignedInt(description[10..13])
def x = hexToSignedInt(description[20..23])
@@ -513,11 +518,6 @@ private Map parseAxis(String description) {
getXyzResult(xyzResults, description)
}
private hexToSignedInt(hexVal) {
def unsignedVal = hexToInt(hexVal)
unsignedVal > 32767 ? unsignedVal - 65536 : unsignedVal
}
def garageEvent(zValue) {
def absValue = zValue.abs()
def contactValue = null

View File

@@ -326,7 +326,6 @@ def addBulbs() {
d = addChildDevice("smartthings", "Hue Bulb", dni, newHueBulb?.value.hub, ["label":newHueBulb?.value.name])
}
log.debug "created ${d.displayName} with id $dni"
d.refresh()
} else {
log.debug "$dni in not longer paired to the Hue Bridge or ID changed"
}
@@ -334,8 +333,8 @@ def addBulbs() {
//backwards compatable
newHueBulb = bulbs.find { (app.id + "/" + it.id) == dni }
d = addChildDevice("smartthings", "Hue Bulb", dni, newHueBulb?.hub, ["label":newHueBulb?.name])
d.refresh()
}
d.refresh()
} else {
log.debug "found ${d.displayName} with id $dni already exists, type: '$d.typeName'"
if (bulbs instanceof java.util.Map) {
@@ -775,4 +774,4 @@ private Boolean hasAllHubsOver(String desiredFirmware) {
private List getRealHubFirmwareVersions() {
return location.hubs*.firmwareVersionString.findAll { it }
}
}

View File

@@ -1,144 +0,0 @@
/**
* Brighten The Darkness
*
* Copyright 2016 Michael Wood
*
* 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: "Brighten The Darkness",
namespace: "woody1130",
author: "Michael Wood",
description: "Turns lights on for X minutes when something happens, with the option to only run after sunset or before sunrise.",
category: "Convenience",
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 {
page(name: "whenHappens", title: "When Something Happens",
nextPage: "doSomething", uninstall: true){
section("When Movement Starts...") {
input "motion1", "capability.motionSensor",
title: "Where?", multiple: true, required: false
}
section("Or A Door Opens...") {
input "contactSensors1", "capability.contactSensor",
title: "Open/close sensors", multiple: true, required: false
}
}
page(name: "doSomething", title: "Turn On The Lights",
nextPage: "nameOfSomeOtherPage", uninstall: true){
section("Turn on a light...") {
input "switch1", "capability.switch", multiple: true
}
section("Time to keep the light on...") {
input "mins", "number", title: "Minutes"
}
section("Use Only When Its Dark...") {
input(name: "boolDark", type: "enum", title: "Yes/No", options: ["Yes","No"])
}
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
subscribe(motion1, "motion.active", motionActiveHandler)
subscribe(contactSensors1, "contact", contactHandler)
}
def contactHandler(evt) {
if("open" == evt.value) {
runActions()
}
}
def motionActiveHandler(evt) {
runActions()
}
def runActions() {
if (isItDarkOut())
{
turnOn()
}
else
{
log.debug("Not Time For Light!!")
}
}
def turnOn() {
//Calculate delay till off in seconds
log.debug("Turning on...")
//Turn lights on
switch1.on()
//Wait and then turn lights off
log.debug("Waiting...")
runIn(60 * mins, timedTurnOff)
}
def timedTurnOff() {
log.debug("Turning Off...")
switch1.off()
}
def isItDarkOut() {
def sunRiseStr = (location.currentValue("sunriseTime"))
def sunSetStr = (location.currentValue("sunsetTime"))
Date sunRise = new Date().parse("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", sunRiseStr).plus(-1)
Date sunSet = new Date().parse("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", sunSetStr).plus(-1)
Date now = new Date()
if ((now < sunRise) || (now > sunSet) || (boolDark == "No")){
return true
}
else{
return false
}
}