mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-04-03 14:23:07 +01:00
Compare commits
1 Commits
PROD_2017.
...
MSA-1830-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9db4b7679a |
@@ -24,11 +24,10 @@ metadata {
|
|||||||
capability "Health Check"
|
capability "Health Check"
|
||||||
|
|
||||||
fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x22, 0x85, 0x59, 0x20, 0x80, 0x70, 0x56, 0x5A, 0x7A, 0x72, 0x8E, 0x71, 0x73, 0x98, 0x9C, 0x31, 0x86", outClusters: ""
|
fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x22, 0x85, 0x59, 0x20, 0x80, 0x70, 0x56, 0x5A, 0x7A, 0x72, 0x8E, 0x71, 0x73, 0x98, 0x9C, 0x31, 0x86", outClusters: ""
|
||||||
fingerprint mfr:"010F", prod:"0B01", model:"2002"
|
|
||||||
fingerprint mfr:"010F", prod:"0B01", model:"1002"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
simulator {
|
simulator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles(scale: 2) {
|
tiles(scale: 2) {
|
||||||
@@ -124,9 +123,11 @@ def zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd)
|
|||||||
{
|
{
|
||||||
def event = createEvent(descriptionText: "${device.displayName} woke up", displayed: false)
|
def event = createEvent(descriptionText: "${device.displayName} woke up", displayed: false)
|
||||||
def cmds = []
|
def cmds = []
|
||||||
// cmds << encap(zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType: 1, scale: 0))
|
|
||||||
// cmds << "delay 500"
|
|
||||||
cmds << encap(zwave.batteryV1.batteryGet())
|
cmds << encap(zwave.batteryV1.batteryGet())
|
||||||
|
cmds << "delay 500"
|
||||||
|
cmds << encap(zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType: 1, scale: 0))
|
||||||
|
cmds << "delay 1200"
|
||||||
|
cmds << encap(zwave.wakeUpV1.wakeUpNoMoreInformation())
|
||||||
[event, response(cmds)]
|
[event, response(cmds)]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,19 +154,6 @@ def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecifi
|
|||||||
updateDataValue("serialNumber", serialNumber)
|
updateDataValue("serialNumber", serialNumber)
|
||||||
log.debug "${device.displayName} - serial number: ${serialNumber}"
|
log.debug "${device.displayName} - serial number: ${serialNumber}"
|
||||||
}
|
}
|
||||||
|
|
||||||
def response_cmds = []
|
|
||||||
if (!device.currentState("temperature")) {
|
|
||||||
response_cmds << encap(zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType: 1, scale: 0))
|
|
||||||
}
|
|
||||||
if (!getDataValue("version") && !zwaveInfo.ver) {
|
|
||||||
log.debug "Requesting Version Report"
|
|
||||||
response_cmds << "delay 500"
|
|
||||||
response_cmds << encap(zwave.versionV1.versionGet())
|
|
||||||
}
|
|
||||||
response_cmds << "delay 1000"
|
|
||||||
response_cmds << encap(zwave.wakeUpV2.wakeUpNoMoreInformation())
|
|
||||||
[[:], response(response_cmds)]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {
|
def zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {
|
||||||
@@ -178,20 +166,12 @@ def zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {
|
def zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {
|
||||||
def result = []
|
|
||||||
def map = [:]
|
def map = [:]
|
||||||
map.name = "battery"
|
map.name = "battery"
|
||||||
map.value = cmd.batteryLevel == 255 ? 1 : cmd.batteryLevel.toString()
|
map.value = cmd.batteryLevel == 255 ? 1 : cmd.batteryLevel.toString()
|
||||||
map.unit = "%"
|
map.unit = "%"
|
||||||
|
map.displayed = true
|
||||||
result << createEvent(map)
|
createEvent(map)
|
||||||
|
|
||||||
if (!getDataValue("serialNumber")) {
|
|
||||||
result << response(encap(zwave.manufacturerSpecificV2.deviceSpecificGet()))
|
|
||||||
} else {
|
|
||||||
result << response(encap(zwave.wakeUpV2.wakeUpNoMoreInformation()))
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {
|
def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {
|
||||||
@@ -249,18 +229,21 @@ def zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLoca
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Executing 'configure'"
|
log.debug "Executing 'configure'"
|
||||||
// Device wakes up every 4 hours, this interval of 8h 2m allows us to miss one wakeup notification before marking offline
|
// Device-Watch simply pings if no device events received for 8 hrs & 2 minutes
|
||||||
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
||||||
|
|
||||||
// default initial state
|
|
||||||
sendEvent(name: "water", value: "dry")
|
|
||||||
|
|
||||||
def cmds = []
|
def cmds = []
|
||||||
|
|
||||||
cmds << zwave.associationV2.associationSet(groupingIdentifier:1, nodeId: [zwaveHubNodeId])
|
cmds += zwave.wakeUpV2.wakeUpIntervalSet(seconds:21600, nodeid: zwaveHubNodeId)//FGFS' default wake up interval
|
||||||
cmds << zwave.batteryV1.batteryGet() // other queries sent as response to BatteryReport
|
cmds += zwave.manufacturerSpecificV2.manufacturerSpecificGet()
|
||||||
|
cmds += zwave.manufacturerSpecificV2.deviceSpecificGet()
|
||||||
|
cmds += zwave.versionV1.versionGet()
|
||||||
|
cmds += zwave.batteryV1.batteryGet()
|
||||||
|
cmds += zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType: 1, scale: 0)
|
||||||
|
cmds += zwave.associationV2.associationSet(groupingIdentifier:1, nodeId: [zwaveHubNodeId])
|
||||||
|
cmds += zwave.wakeUpV2.wakeUpNoMoreInformation()
|
||||||
|
|
||||||
encapSequence(cmds, 200)
|
encapSequence(cmds, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
private secure(physicalgraph.zwave.Command cmd) {
|
private secure(physicalgraph.zwave.Command cmd) {
|
||||||
@@ -277,10 +260,13 @@ private encapSequence(commands, delay=200) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private encap(physicalgraph.zwave.Command cmd) {
|
private encap(physicalgraph.zwave.Command cmd) {
|
||||||
if (zwaveInfo.zw && !zwaveInfo.zw.contains("s")) {
|
def secureClasses = [0x20, 0x5A, 0x70, 0x71, 0x84, 0x85, 0x8E, 0x9C]
|
||||||
// Secure inclusion failed
|
|
||||||
crc16(cmd)
|
//todo: check if secure inclusion was successful
|
||||||
} else {
|
//if not do not send security-encapsulated command
|
||||||
|
if (secureClasses.find{ it == cmd.commandClassId }) {
|
||||||
secure(cmd)
|
secure(cmd)
|
||||||
|
} else {
|
||||||
|
crc16(cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,9 +47,6 @@ metadata {
|
|||||||
command "test"
|
command "test"
|
||||||
|
|
||||||
fingerprint deviceId: "0xA102", inClusters: "0x30,0x9C,0x60,0x85,0x8E,0x72,0x70,0x86,0x80,0x84"
|
fingerprint deviceId: "0xA102", inClusters: "0x30,0x9C,0x60,0x85,0x8E,0x72,0x70,0x86,0x80,0x84"
|
||||||
fingerprint mfr:"010F", prod:"0000", model:"2002"
|
|
||||||
fingerprint mfr:"010F", prod:"0000", model:"1002"
|
|
||||||
fingerprint mfr:"010F", prod:"0B00", model:"1001"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
simulator {
|
simulator {
|
||||||
@@ -111,11 +108,20 @@ def parse(String description)
|
|||||||
{
|
{
|
||||||
def result = []
|
def result = []
|
||||||
|
|
||||||
|
if (description == "updated") {
|
||||||
|
if (!state.MSR) {
|
||||||
|
result << response(zwave.wakeUpV1.wakeUpIntervalSet(seconds: 60*60, nodeid:zwaveHubNodeId))
|
||||||
|
result << response(zwave.manufacturerSpecificV2.manufacturerSpecificGet())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
def cmd = zwave.parse(description, [0x31: 2, 0x30: 1, 0x70: 2, 0x71: 1, 0x84: 1, 0x80: 1, 0x9C: 1, 0x72: 2, 0x56: 2, 0x60: 3])
|
def cmd = zwave.parse(description, [0x31: 2, 0x30: 1, 0x70: 2, 0x71: 1, 0x84: 1, 0x80: 1, 0x9C: 1, 0x72: 2, 0x56: 2, 0x60: 3])
|
||||||
|
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
result += zwaveEvent(cmd) //createEvent(zwaveEvent(cmd))
|
result += zwaveEvent(cmd) //createEvent(zwaveEvent(cmd))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result << response(zwave.batteryV1.batteryGet().format())
|
||||||
|
|
||||||
if ( result[0] != null ) {
|
if ( result[0] != null ) {
|
||||||
log.debug "Parse returned ${result}"
|
log.debug "Parse returned ${result}"
|
||||||
@@ -137,9 +143,10 @@ def zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd) {
|
|||||||
def result = [createEvent(descriptionText: "${device.displayName} woke up", isStateChange: false)]
|
def result = [createEvent(descriptionText: "${device.displayName} woke up", isStateChange: false)]
|
||||||
if (!isConfigured()) {
|
if (!isConfigured()) {
|
||||||
// we're still in the process of configuring a newly joined device
|
// we're still in the process of configuring a newly joined device
|
||||||
result << lateConfigure(true)
|
result += lateConfigure(true)
|
||||||
} else {
|
} else {
|
||||||
result << response(zwave.wakeUpV1.wakeUpNoMoreInformation())
|
result += response(zwave.wakeUpV1.wakeUpNoMoreInformation())
|
||||||
|
log.debug "We're done with WakeUp!"
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
@@ -298,12 +305,9 @@ def lateConfigure(setConf = False) {
|
|||||||
*/
|
*/
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Configuring Device..."
|
log.debug "Configuring Device..."
|
||||||
// Device wakes up every 4 hours, this interval allows us to miss one wakeup notification before marking offline
|
// Device-Watch simply pings if no device events received for 8 hrs & 2 minutes
|
||||||
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
||||||
|
|
||||||
// default initial state
|
|
||||||
sendEvent(name: "water", value: "dry")
|
|
||||||
|
|
||||||
def cmds = []
|
def cmds = []
|
||||||
|
|
||||||
// send associate to group 2 to get alarm data
|
// send associate to group 2 to get alarm data
|
||||||
@@ -314,15 +318,13 @@ def configure() {
|
|||||||
// send associate to group 3 to get sensor data reported only to hub
|
// send associate to group 3 to get sensor data reported only to hub
|
||||||
cmds << zwave.associationV2.associationSet(groupingIdentifier:3, nodeId:[zwaveHubNodeId]).format()
|
cmds << zwave.associationV2.associationSet(groupingIdentifier:3, nodeId:[zwaveHubNodeId]).format()
|
||||||
|
|
||||||
// reporting frequency of temps and battery set to one hour
|
|
||||||
cmds << zwave.configurationV1.configurationSet(configurationValue: [0,60*60], parameterNumber: 10, size: 2).format()
|
|
||||||
// cmds << zwave.configurationV1.configurationGet(parameterNumber: 10).format()
|
|
||||||
|
|
||||||
// temp hysteresis set to .5 degrees celcius
|
// temp hysteresis set to .5 degrees celcius
|
||||||
cmds << zwave.configurationV1.configurationSet(configurationValue: [0,50], parameterNumber: 12, size: 2).format()
|
cmds << zwave.configurationV1.configurationSet(configurationValue: [0,50], parameterNumber: 12, size: 2).format()
|
||||||
// cmds << zwave.configurationV1.configurationGet(parameterNumber: 12).format()
|
cmds << zwave.configurationV1.configurationGet(parameterNumber: 12).format()
|
||||||
|
|
||||||
cmds << zwave.batteryV1.batteryGet().format()
|
// reporting frequency of temps and battery set to one hour
|
||||||
|
cmds << zwave.configurationV1.configurationSet(configurationValue: [0,60*60], parameterNumber: 10, size: 2).format()
|
||||||
|
cmds << zwave.configurationV1.configurationGet(parameterNumber: 10).format()
|
||||||
|
|
||||||
cmds << zwave.wakeUpV1.wakeUpNoMoreInformation().format()
|
cmds << zwave.wakeUpV1.wakeUpNoMoreInformation().format()
|
||||||
|
|
||||||
|
|||||||
@@ -1,169 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2016 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:
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
import groovy.transform.Field
|
|
||||||
|
|
||||||
@Field Boolean hasConfiguredHealthCheck = false
|
|
||||||
|
|
||||||
metadata {
|
|
||||||
definition (name: "ZLL White Color Temperature Bulb 5000K", namespace: "smartthings", author: "SmartThings") {
|
|
||||||
|
|
||||||
capability "Actuator"
|
|
||||||
capability "Color Temperature"
|
|
||||||
capability "Configuration"
|
|
||||||
capability "Polling"
|
|
||||||
capability "Refresh"
|
|
||||||
capability "Switch"
|
|
||||||
capability "Switch Level"
|
|
||||||
capability "Health Check"
|
|
||||||
|
|
||||||
attribute "colorName", "string"
|
|
||||||
command "setGenericName"
|
|
||||||
|
|
||||||
fingerprint profileId: "C05E", deviceId: "0220", inClusters: "0000, 0004, 0003, 0006, 0008, 0005, 0300", outClusters: "0019", manufacturer: "Eaton", model: "Halo_LT01", deviceJoinName: "Halo RL56 Wireless"
|
|
||||||
}
|
|
||||||
|
|
||||||
// UI tile definitions
|
|
||||||
tiles(scale: 2) {
|
|
||||||
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
|
|
||||||
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
|
|
||||||
attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#00A0DC", nextState:"turningOff"
|
|
||||||
attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
|
|
||||||
attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#00A0DC", nextState:"turningOff"
|
|
||||||
attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
|
|
||||||
}
|
|
||||||
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
|
||||||
attributeState "level", action:"switch level.setLevel"
|
|
||||||
}
|
|
||||||
tileAttribute ("colorName", key: "SECONDARY_CONTROL") {
|
|
||||||
attributeState "colorName", label:'${currentValue}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
|
||||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
|
||||||
}
|
|
||||||
|
|
||||||
controlTile("colorTempSliderControl", "device.colorTemperature", "slider", width: 4, height: 2, inactiveLabel: false, range:"(2700..5000)") {
|
|
||||||
state "colorTemperature", action:"color temperature.setColorTemperature"
|
|
||||||
}
|
|
||||||
valueTile("colorTemp", "device.colorTemperature", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
|
||||||
state "colorTemperature", label: '${currentValue} K'
|
|
||||||
}
|
|
||||||
|
|
||||||
main(["switch"])
|
|
||||||
details(["switch", "colorTempSliderControl", "colorTemp", "refresh"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse incoming device messages to generate events
|
|
||||||
def parse(String description) {
|
|
||||||
log.debug "description is $description"
|
|
||||||
def event = zigbee.getEvent(description)
|
|
||||||
if (event) {
|
|
||||||
if (event.name == "colorTemperature") {
|
|
||||||
event.unit = "K"
|
|
||||||
}
|
|
||||||
sendEvent(event)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log.warn "DID NOT PARSE MESSAGE for description : $description"
|
|
||||||
log.debug zigbee.parseDescriptionAsMap(description)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def off() {
|
|
||||||
zigbee.off() + ["delay 1500"] + zigbee.onOffRefresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
def on() {
|
|
||||||
zigbee.on() + ["delay 1500"] + zigbee.onOffRefresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
def setLevel(value) {
|
|
||||||
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
def refresh() {
|
|
||||||
def cmds = zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
|
||||||
|
|
||||||
// Do NOT config if the device is the Eaton Halo_LT01, it responds with "switch:off" to onOffConfig, and maybe other weird things with the others
|
|
||||||
if (!((device.getDataValue("manufacturer") == "Eaton") && (device.getDataValue("model") == "Halo_LT01"))) {
|
|
||||||
cmds = cmds + zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig()
|
|
||||||
}
|
|
||||||
|
|
||||||
cmds
|
|
||||||
}
|
|
||||||
|
|
||||||
def poll() {
|
|
||||||
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PING is used by Device-Watch in attempt to reach the Device
|
|
||||||
* */
|
|
||||||
def ping() {
|
|
||||||
return zigbee.levelRefresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
def healthPoll() {
|
|
||||||
log.debug "healthPoll()"
|
|
||||||
def cmds = zigbee.onOffRefresh() + zigbee.levelRefresh()
|
|
||||||
cmds.each{ sendHubCommand(new physicalgraph.device.HubAction(it))}
|
|
||||||
}
|
|
||||||
|
|
||||||
def configureHealthCheck() {
|
|
||||||
Integer hcIntervalMinutes = 12
|
|
||||||
if (!hasConfiguredHealthCheck) {
|
|
||||||
log.debug "Configuring Health Check, Reporting"
|
|
||||||
unschedule("healthPoll")
|
|
||||||
runEvery5Minutes("healthPoll")
|
|
||||||
// Device-Watch allows 2 check-in misses from device
|
|
||||||
sendEvent(name: "checkInterval", value: hcIntervalMinutes * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
|
||||||
hasConfiguredHealthCheck = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def configure() {
|
|
||||||
log.debug "configure()"
|
|
||||||
configureHealthCheck()
|
|
||||||
// Implementation note: for the Eaton Halo_LT01, it responds with "switch:off" to onOffConfig, so be sure this is before the call to onOffRefresh
|
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
def updated() {
|
|
||||||
log.debug "updated()"
|
|
||||||
configureHealthCheck()
|
|
||||||
}
|
|
||||||
|
|
||||||
def setColorTemperature(value) {
|
|
||||||
setGenericName(value)
|
|
||||||
zigbee.setColorTemperature(value) + ["delay 1500"] + zigbee.colorTemperatureRefresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
//Naming based on the wiki article here: http://en.wikipedia.org/wiki/Color_temperature
|
|
||||||
def setGenericName(value){
|
|
||||||
if (value != null) {
|
|
||||||
def genericName = ""
|
|
||||||
if (value < 3300) {
|
|
||||||
genericName = "Soft White"
|
|
||||||
} else if (value < 4150) {
|
|
||||||
genericName = "Moonlight"
|
|
||||||
} else if (value <= 5000) {
|
|
||||||
genericName = "Cool White"
|
|
||||||
} else {
|
|
||||||
genericName = "Daylight"
|
|
||||||
}
|
|
||||||
sendEvent(name: "colorName", value: genericName, displayed: false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
130
smartapps/foxtechnology/thermosmart.src/thermosmart.groovy
Normal file
130
smartapps/foxtechnology/thermosmart.src/thermosmart.groovy
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2016 M. Fox
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Based on:
|
||||||
|
* Keep Me Cozy
|
||||||
|
* Author: SmartThings
|
||||||
|
*/
|
||||||
|
definition(
|
||||||
|
name: "Thermosmart",
|
||||||
|
namespace: "foxtechnology",
|
||||||
|
author: "M. Fox",
|
||||||
|
description: "V1.1n: Changes your thermostat settings automatically in response to a mode change. You can either SET the thermostate to your desired temperature or RESUME the regular schedule. ",
|
||||||
|
category: "Green Living",
|
||||||
|
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo.png",
|
||||||
|
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo@2x.png"
|
||||||
|
)
|
||||||
|
|
||||||
|
preferences {
|
||||||
|
page(name: "setThermostat")
|
||||||
|
}
|
||||||
|
|
||||||
|
def setThermostat() {
|
||||||
|
dynamicPage(name: "setThermostat", title: null, install: true, uninstall: true) {
|
||||||
|
|
||||||
|
section{
|
||||||
|
input(name: "thermostats", type: "capability.thermostat", title: "Thermostats",
|
||||||
|
description: null, multiple: true, required: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
section{
|
||||||
|
input(name: "state", type: "enum", title: "State",
|
||||||
|
description: null, multiple: false, required: true, options: ["Set","Resume"], submitOnChange: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
label title: "Assign a name", required: false
|
||||||
|
mode title: "Set for specific mode(s)", required: true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.state == "Set") {
|
||||||
|
section {
|
||||||
|
input(name: "heatingSetpoint", type: "number", title: "Heating Setpoint Degrees?", required: true)
|
||||||
|
}
|
||||||
|
section {
|
||||||
|
input(name: "coolingSetpoint", type: "number", title: "Cooling Setpoint Degrees?", required: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def installed()
|
||||||
|
{
|
||||||
|
subscribe(thermostats, "heatingSetpoint", heatingSetpointHandler)
|
||||||
|
subscribe(thermostats, "coolingSetpoint", coolingSetpointHandler)
|
||||||
|
subscribe(thermostats, "temperature", temperatureHandler)
|
||||||
|
subscribe(location, changedLocationMode)
|
||||||
|
subscribe(app, appTouch)
|
||||||
|
}
|
||||||
|
|
||||||
|
def updated()
|
||||||
|
{
|
||||||
|
unsubscribe()
|
||||||
|
subscribe(thermostats, "heatingSetpoint", heatingSetpointHandler)
|
||||||
|
subscribe(thermostats, "coolingSetpoint", coolingSetpointHandler)
|
||||||
|
subscribe(thermostats, "temperature", temperatureHandler)
|
||||||
|
subscribe(location, changedLocationMode)
|
||||||
|
subscribe(app, appTouch)
|
||||||
|
}
|
||||||
|
|
||||||
|
def heatingSetpointHandler(evt)
|
||||||
|
{
|
||||||
|
log.debug "heatingSetpointHandler: $evt, $settings"
|
||||||
|
}
|
||||||
|
|
||||||
|
def coolingSetpointHandler(evt)
|
||||||
|
{
|
||||||
|
log.debug "coolingSetpointHandler: $evt, $settings"
|
||||||
|
}
|
||||||
|
|
||||||
|
def temperatureHandler(evt)
|
||||||
|
{
|
||||||
|
log.debug "TemperatureHandler: $evt, $settings"
|
||||||
|
}
|
||||||
|
|
||||||
|
def changedLocationMode(evt)
|
||||||
|
{
|
||||||
|
if(settings.state == "Set")
|
||||||
|
{
|
||||||
|
thermostats.setHeatingSetpoint(heatingSetpoint)
|
||||||
|
thermostats.setCoolingSetpoint(coolingSetpoint)
|
||||||
|
}
|
||||||
|
else if (settings.state == "Resume")
|
||||||
|
{
|
||||||
|
thermostats.resumeProgram()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
def appTouch(evt)
|
||||||
|
{
|
||||||
|
log.debug "appTouch: $evt, $settings"
|
||||||
|
log.debug "Current state: $settings.state"
|
||||||
|
if(settings.state == "Set"){
|
||||||
|
settings.state = "Resume"
|
||||||
|
log.debug "setting state to Reset: $settings.state"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
settings.state = "Set"
|
||||||
|
log.debug "setting state to Set: $settings.state"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// catchall
|
||||||
|
def event(evt)
|
||||||
|
{
|
||||||
|
log.debug "value: $evt.value, event: $evt, settings: $settings, handlerName: ${evt.handlerName}"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user