Update zwave-thermostat.groovy

This commit is contained in:
Ingvar Marstorp
2017-08-10 12:23:50 -07:00
committed by GitHub
parent eb9b55e01c
commit 2b09b7c574

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"
@@ -128,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)
@@ -318,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())