Merge pull request #2231 from marstorp/dvcsmp2973

DVCSMP-2973 CT100/Honeywell Z-wave NullPointerException
This commit is contained in:
dsainteclaire
2017-08-10 16:52:35 -07:00
committed by GitHub
2 changed files with 49 additions and 47 deletions

View File

@@ -18,6 +18,7 @@ metadata {
command "raiseHeatingSetpoint" command "raiseHeatingSetpoint"
command "lowerCoolSetpoint" command "lowerCoolSetpoint"
command "raiseCoolSetpoint" command "raiseCoolSetpoint"
command "poll"
fingerprint deviceId: "0x08", inClusters: "0x43,0x40,0x44,0x31,0x80,0x85,0x60" fingerprint deviceId: "0x08", inClusters: "0x43,0x40,0x44,0x31,0x80,0x85,0x60"
fingerprint mfr:"0098", prod:"6401", model:"0107", deviceJoinName: "2Gig CT100 Programmable Thermostat" fingerprint mfr:"0098", prod:"6401", model:"0107", deviceJoinName: "2Gig CT100 Programmable Thermostat"
@@ -101,9 +102,8 @@ metadata {
def installed() { def installed() {
// Configure device // Configure device
def cmds = [] def cmds = [new physicalgraph.device.HubAction(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:[zwaveHubNodeId]).format()),
cmds << new physicalgraph.device.HubAction(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:[zwaveHubNodeId]).format()) new physicalgraph.device.HubAction(zwave.manufacturerSpecificV2.manufacturerSpecificGet().format())]
cmds << new physicalgraph.device.HubAction(zwave.manufacturerSpecificV2.manufacturerSpecificGet().format())
sendHubCommand(cmds) sendHubCommand(cmds)
runIn(3, "initialize", [overwrite: true]) // Allow configure command to be sent and acknowledged before proceeding runIn(3, "initialize", [overwrite: true]) // Allow configure command to be sent and acknowledged before proceeding
} }
@@ -123,7 +123,7 @@ def initialize() {
// Device-Watch simply pings if no device events received for 32min(checkInterval) // Device-Watch simply pings if no device events received for 32min(checkInterval)
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID]) sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
// Poll device for additional data that will be updated by refresh tile // Poll device for additional data that will be updated by refresh tile
poll() pollDevice()
} }
def parse(String description) def parse(String description)
@@ -150,7 +150,6 @@ def parse(String description)
def zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiInstanceCmdEncap cmd) { def zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiInstanceCmdEncap cmd) {
def encapsulatedCommand = cmd.encapsulatedCommand([0x31: 3]) def encapsulatedCommand = cmd.encapsulatedCommand([0x31: 3])
log.debug ("multiinstancev1.MultiInstanceCmdEncap: command from instance ${cmd.instance}: ${encapsulatedCommand}")
if (encapsulatedCommand) { if (encapsulatedCommand) {
zwaveEvent(encapsulatedCommand) zwaveEvent(encapsulatedCommand)
} }
@@ -341,7 +340,7 @@ def zwaveEvent(physicalgraph.zwave.commands.thermostatmodev2.ThermostatModeSuppo
if(cmd.auxiliaryemergencyHeat) { supportedModes << "emergency heat" } if(cmd.auxiliaryemergencyHeat) { supportedModes << "emergency heat" }
state.supportedModes = supportedModes state.supportedModes = supportedModes
sendEvent(name: "supportedThermostatModes", value: supportedModes, isStateChange: true, displayed: false) sendEvent(name: "supportedThermostatModes", value: supportedModes, displayed: false)
} }
def zwaveEvent(physicalgraph.zwave.commands.thermostatfanmodev3.ThermostatFanModeSupportedReport cmd) { def zwaveEvent(physicalgraph.zwave.commands.thermostatfanmodev3.ThermostatFanModeSupportedReport cmd) {
@@ -351,7 +350,7 @@ def zwaveEvent(physicalgraph.zwave.commands.thermostatfanmodev3.ThermostatFanMod
if(cmd.circulation) { supportedFanModes << "circulate" } if(cmd.circulation) { supportedFanModes << "circulate" }
state.supportedFanModes = supportedFanModes state.supportedFanModes = supportedFanModes
sendEvent(name: "supportedThermostatFanModes", value: supportedFanModes, isStateChange: true, displayed: false) sendEvent(name: "supportedThermostatFanModes", value: supportedFanModes, displayed: false)
} }
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) { def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
@@ -377,7 +376,6 @@ def zwaveEvent(physicalgraph.zwave.Command cmd) {
} }
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) { def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
log.debug "ManufacturerSpecificReport ${cmd}: value:${cmd}"
if (cmd.manufacturerName) { if (cmd.manufacturerName) {
updateDataValue("manufacturer", cmd.manufacturerName) updateDataValue("manufacturer", cmd.manufacturerName)
} }
@@ -389,6 +387,11 @@ log.debug "ManufacturerSpecificReport ${cmd}: value:${cmd}"
} }
} }
def poll() {
// Call refresh which will cap the polling to once every 2 minutes
refresh()
}
def refresh() { def refresh() {
// Only allow refresh every 2 minutes to prevent flooding the Zwave network // Only allow refresh every 2 minutes to prevent flooding the Zwave network
def timeNow = now() def timeNow = now()
@@ -397,11 +400,11 @@ def refresh() {
// refresh will request battery, prevent multiple request by setting lastbatt now // refresh will request battery, prevent multiple request by setting lastbatt now
state.lastbatt = timeNow state.lastbatt = timeNow
// use runIn with overwrite to prevent multiple DTH instances run before state.refreshTriggeredAt has been saved // use runIn with overwrite to prevent multiple DTH instances run before state.refreshTriggeredAt has been saved
runIn(2, "poll", [overwrite: true]) runIn(2, "pollDevice", [overwrite: true])
} }
} }
def poll() { def pollDevice() {
def cmds = [] def cmds = []
cmds << new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeSupportedGet().format()) cmds << new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeSupportedGet().format())
cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSupportedGet().format()) cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSupportedGet().format())
@@ -614,7 +617,7 @@ def updateThermostatSetpoint(setpoint, value) {
* */ * */
def ping() { def ping() {
log.debug "ping() called" log.debug "ping() called"
// Just get Operating State as it is not reported when it chnages and there's no need to flood more commands // Just get Operating State as it is not reported when it changes and there's no need to flood more commands
sendHubCommand(new physicalgraph.device.HubAction(zwave.thermostatOperatingStateV1.thermostatOperatingStateGet().format())) sendHubCommand(new physicalgraph.device.HubAction(zwave.thermostatOperatingStateV1.thermostatOperatingStateGet().format()))
} }
@@ -624,7 +627,7 @@ def switchMode() {
if (supportedModes) { if (supportedModes) {
def next = { supportedModes[supportedModes.indexOf(it) + 1] ?: supportedModes[0] } def next = { supportedModes[supportedModes.indexOf(it) + 1] ?: supportedModes[0] }
def nextMode = next(currentMode) def nextMode = next(currentMode)
runIn(2, "setThermostatMode", [data: [nextMode: nextMode], overwrite: true]) runIn(2, "setGetThermostatMode", [data: [nextMode: nextMode], overwrite: true])
} else { } else {
log.warn "supportedModes not defined" log.warn "supportedModes not defined"
getSupportedModes() getSupportedModes()
@@ -635,7 +638,7 @@ def switchToMode(nextMode) {
def supportedModes = state.supportedModes def supportedModes = state.supportedModes
if (supportedModes) { if (supportedModes) {
if (supportedModes.contains(nextMode)) { if (supportedModes.contains(nextMode)) {
runIn(2, "setThermostatMode", [data: [nextMode: nextMode], overwrite: true]) runIn(2, "setGetThermostatMode", [data: [nextMode: nextMode], overwrite: true])
} else { } else {
log.debug("ThermostatMode $nextMode is not supported by ${device.displayName}") log.debug("ThermostatMode $nextMode is not supported by ${device.displayName}")
} }
@@ -657,7 +660,7 @@ def switchFanMode() {
if (supportedFanModes) { if (supportedFanModes) {
def next = { supportedFanModes[supportedFanModes.indexOf(it) + 1] ?: supportedFanModes[0] } def next = { supportedFanModes[supportedFanModes.indexOf(it) + 1] ?: supportedFanModes[0] }
def nextMode = next(currentMode) def nextMode = next(currentMode)
runIn(2, "setThermostatFanMode", [data: [nextMode: nextMode], overwrite: true]) runIn(2, "setGetThermostatFanMode", [data: [nextMode: nextMode], overwrite: true])
} else { } else {
log.warn "supportedFanModes not defined" log.warn "supportedFanModes not defined"
getSupportedFanModes() getSupportedFanModes()
@@ -668,7 +671,7 @@ def switchToFanMode(nextMode) {
def supportedFanModes = state.supportedFanModes def supportedFanModes = state.supportedFanModes
if (supportedFanModes) { if (supportedFanModes) {
if (supportedFanModes.contains(nextMode)) { if (supportedFanModes.contains(nextMode)) {
runIn(2, "setThermostatFanMode", [data: [nextMode: nextMode], overwrite: true]) runIn(2, "setGetThermostatFanMode", [data: [nextMode: nextMode], overwrite: true])
} else { } else {
log.debug("FanMode $nextMode is not supported by ${device.displayName}") log.debug("FanMode $nextMode is not supported by ${device.displayName}")
} }
@@ -679,8 +682,7 @@ def switchToFanMode(nextMode) {
} }
def getSupportedFanModes() { def getSupportedFanModes() {
def cmds = [] def cmds = [new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSupportedGet().format())]
cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSupportedGet().format())
sendHubCommand(cmds) sendHubCommand(cmds)
} }
@@ -696,10 +698,9 @@ def setThermostatMode(String value) {
switchToMode(value) switchToMode(value)
} }
def setThermostatMode(data) { def setGetThermostatMode(data) {
def cmds = [] def cmds = [new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeSet(mode: modeMap[data.nextMode]).format()),
cmds << new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeSet(mode: modeMap[data.nextMode]).format()) new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeGet().format())]
cmds << new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeGet().format())
sendHubCommand(cmds) sendHubCommand(cmds)
} }
@@ -713,10 +714,9 @@ def setThermostatFanMode(String value) {
switchToFanMode(value) switchToFanMode(value)
} }
def setThermostatFanMode(data) { def setGetThermostatFanMode(data) {
def cmds = [] def cmds = [new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSet(fanMode: fanModeMap[data.nextMode]).format()),
cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSet(fanMode: fanModeMap[data.nextMode]).format()) new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeGet().format())]
cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeGet().format())
sendHubCommand(cmds) sendHubCommand(cmds)
} }

View File

@@ -28,6 +28,7 @@ metadata {
command "raiseHeatingSetpoint" command "raiseHeatingSetpoint"
command "lowerCoolSetpoint" command "lowerCoolSetpoint"
command "raiseCoolSetpoint" command "raiseCoolSetpoint"
command "poll"
fingerprint deviceId: "0x08" fingerprint deviceId: "0x08"
fingerprint inClusters: "0x43,0x40,0x44,0x31" fingerprint inClusters: "0x43,0x40,0x44,0x31"
@@ -91,7 +92,7 @@ metadata {
standardTile("raiseCoolSetpoint", "device.heatingSetpoint", width:2, height:1, inactiveLabel: false, decoration: "flat") { standardTile("raiseCoolSetpoint", "device.heatingSetpoint", width:2, height:1, inactiveLabel: false, decoration: "flat") {
state "heatingSetpoint", action:"raiseCoolSetpoint", icon:"st.thermostat.thermostat-right" state "heatingSetpoint", action:"raiseCoolSetpoint", icon:"st.thermostat.thermostat-right"
} }
valueTile("thermostatOperatingState", "device.thermostatOperatingState", width: 2, height:1, decoration: "flat") { standardTile("thermostatOperatingState", "device.thermostatOperatingState", width: 2, height:1, decoration: "flat") {
state "thermostatOperatingState", label:'${currentValue}', backgroundColor:"#ffffff" state "thermostatOperatingState", label:'${currentValue}', backgroundColor:"#ffffff"
} }
standardTile("refresh", "device.thermostatMode", width:2, height:1, inactiveLabel: false, decoration: "flat") { standardTile("refresh", "device.thermostatMode", width:2, height:1, inactiveLabel: false, decoration: "flat") {
@@ -105,9 +106,8 @@ metadata {
def installed() { def installed() {
// Configure device // Configure device
def cmds = [] def cmds = [new physicalgraph.device.HubAction(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:[zwaveHubNodeId]).format()),
cmds << new physicalgraph.device.HubAction(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:[zwaveHubNodeId]).format()) new physicalgraph.device.HubAction(zwave.manufacturerSpecificV2.manufacturerSpecificGet().format())]
cmds << new physicalgraph.device.HubAction(zwave.manufacturerSpecificV2.manufacturerSpecificGet().format())
sendHubCommand(cmds) sendHubCommand(cmds)
runIn(3, "initialize", [overwrite: true]) // Allow configure command to be sent and acknowledged before proceeding runIn(3, "initialize", [overwrite: true]) // Allow configure command to be sent and acknowledged before proceeding
} }
@@ -129,7 +129,7 @@ def initialize() {
if (getDataValue("manufacturer") != "Honeywell") { if (getDataValue("manufacturer") != "Honeywell") {
runEvery5Minutes("poll") // This is not necessary for Honeywell Z-wave, but could be for other Z-wave thermostats runEvery5Minutes("poll") // This is not necessary for Honeywell Z-wave, but could be for other Z-wave thermostats
} }
poll() pollDevice()
} }
def parse(String description) def parse(String description)
@@ -319,17 +319,22 @@ def zwaveEvent(physicalgraph.zwave.Command cmd) {
} }
// Command Implementations // Command Implementations
def poll() {
// Call refresh which will cap the polling to once every 2 minutes
refresh()
}
def refresh() { def refresh() {
// Only allow refresh every 2 minutes to prevent flooding the Zwave network // Only allow refresh every 2 minutes to prevent flooding the Zwave network
def timeNow = now() def timeNow = now()
if (!state.refreshTriggeredAt || (2 * 60 * 1000 < (timeNow - state.refreshTriggeredAt))) { if (!state.refreshTriggeredAt || (2 * 60 * 1000 < (timeNow - state.refreshTriggeredAt))) {
state.refreshTriggeredAt = timeNow state.refreshTriggeredAt = timeNow
// use runIn with overwrite to prevent multiple DTH instances run before state.refreshTriggeredAt has been saved // use runIn with overwrite to prevent multiple DTH instances run before state.refreshTriggeredAt has been saved
runIn(2, "poll", [overwrite: true]) runIn(2, "pollDevice", [overwrite: true])
} }
} }
def poll() { def pollDevice() {
def cmds = [] def cmds = []
cmds << new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeSupportedGet().format()) cmds << new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeSupportedGet().format())
cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSupportedGet().format()) cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSupportedGet().format())
@@ -505,7 +510,7 @@ def switchMode() {
if (supportedModes) { if (supportedModes) {
def next = { supportedModes[supportedModes.indexOf(it) + 1] ?: supportedModes[0] } def next = { supportedModes[supportedModes.indexOf(it) + 1] ?: supportedModes[0] }
def nextMode = next(currentMode) def nextMode = next(currentMode)
runIn(2, "setThermostatMode", [data: [nextMode: nextMode], overwrite: true]) runIn(2, "setGetThermostatMode", [data: [nextMode: nextMode], overwrite: true])
} else { } else {
log.warn "supportedModes not defined" log.warn "supportedModes not defined"
getSupportedModes() getSupportedModes()
@@ -516,7 +521,7 @@ def switchToMode(nextMode) {
def supportedModes = state.supportedModes def supportedModes = state.supportedModes
if (supportedModes) { if (supportedModes) {
if (supportedModes.contains(nextMode)) { if (supportedModes.contains(nextMode)) {
runIn(2, "setThermostatMode", [data: [nextMode: nextMode], overwrite: true]) runIn(2, "setGetThermostatMode", [data: [nextMode: nextMode], overwrite: true])
} else { } else {
log.debug("ThermostatMode $nextMode is not supported by ${device.displayName}") log.debug("ThermostatMode $nextMode is not supported by ${device.displayName}")
} }
@@ -538,7 +543,7 @@ def switchFanMode() {
if (supportedFanModes) { if (supportedFanModes) {
def next = { supportedFanModes[supportedFanModes.indexOf(it) + 1] ?: supportedFanModes[0] } def next = { supportedFanModes[supportedFanModes.indexOf(it) + 1] ?: supportedFanModes[0] }
def nextMode = next(currentMode) def nextMode = next(currentMode)
runIn(2, "setThermostatFanMode", [data: [nextMode: nextMode], overwrite: true]) runIn(2, "setGetThermostatFanMode", [data: [nextMode: nextMode], overwrite: true])
} else { } else {
log.warn "supportedFanModes not defined" log.warn "supportedFanModes not defined"
getSupportedFanModes() getSupportedFanModes()
@@ -549,7 +554,7 @@ def switchToFanMode(nextMode) {
def supportedFanModes = state.supportedFanModes def supportedFanModes = state.supportedFanModes
if (supportedFanModes) { if (supportedFanModes) {
if (supportedFanModes.contains(nextMode)) { if (supportedFanModes.contains(nextMode)) {
runIn(2, "setThermostatFanMode", [data: [nextMode: nextMode], overwrite: true]) runIn(2, "setGetThermostatFanMode", [data: [nextMode: nextMode], overwrite: true])
} else { } else {
log.debug("FanMode $nextMode is not supported by ${device.displayName}") log.debug("FanMode $nextMode is not supported by ${device.displayName}")
} }
@@ -560,8 +565,7 @@ def switchToFanMode(nextMode) {
} }
def getSupportedFanModes() { def getSupportedFanModes() {
def cmds = [] def cmds = [new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSupportedGet().format())]
cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSupportedGet().format())
sendHubCommand(cmds) sendHubCommand(cmds)
} }
@@ -577,10 +581,9 @@ def setThermostatMode(String value) {
switchToMode(value) switchToMode(value)
} }
def setThermostatMode(data) { def setGetThermostatMode(data) {
def cmds = [] def cmds = [new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeSet(mode: modeMap[data.nextMode]).format()),
cmds << new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeSet(mode: modeMap[data.nextMode]).format()) new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeGet().format())]
cmds << new physicalgraph.device.HubAction(zwave.thermostatModeV2.thermostatModeGet().format())
sendHubCommand(cmds) sendHubCommand(cmds)
} }
@@ -594,10 +597,9 @@ def setThermostatFanMode(String value) {
switchToFanMode(value) switchToFanMode(value)
} }
def setThermostatFanMode(data) { def setGetThermostatFanMode(data) {
def cmds = [] def cmds = [new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSet(fanMode: fanModeMap[data.nextMode]).format()),
cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeSet(fanMode: fanModeMap[data.nextMode]).format()) new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeGet().format())]
cmds << new physicalgraph.device.HubAction(zwave.thermostatFanModeV3.thermostatFanModeGet().format())
sendHubCommand(cmds) sendHubCommand(cmds)
} }
@@ -663,7 +665,7 @@ def getTempInDeviceScale(temp, scale) {
if (temp && scale) { if (temp && scale) {
def deviceScale = (state.scale == 1) ? "F" : "C" def deviceScale = (state.scale == 1) ? "F" : "C"
return (deviceScale == scale) ? temp : return (deviceScale == scale) ? temp :
(deviceScale == "F" ? celsiusToFahrenheit(temp) : roundC(fahrenheitToCelsius(temp))) (deviceScale == "F" ? celsiusToFahrenheit(temp).toDouble().round(0).toInteger() : roundC(fahrenheitToCelsius(temp)))
} }
return 0 return 0
} }