Skip to content

Commit

Permalink
Add work-around for Ki Zigbee operating state firmware bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dkirker committed Dec 19, 2018
1 parent 1d1546a commit f78b14b
Showing 1 changed file with 19 additions and 14 deletions.
Expand Up @@ -163,10 +163,6 @@ def getModeMap() {[
"05":"eco"
]}

def getDutyCyclePeriod() {
15 // seconds
}

def setupHealthCheck() {
// 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: "zigbee", hubHardwareId: device.hub.hardwareID])
Expand Down Expand Up @@ -254,12 +250,7 @@ def parse(String description) {
map.unit = getTemperatureScale()
map.data = [heatingSetpointRange: heatingSetpointRange]

// Sometimes we don't get an updated operating state when going from heating -> idle with a setpoint just below ambient;
// so ask for the operating state, but wait 1.5 times the duty cycle period.
def ambientTemp = device.currentValue("temperature")
if (ambientTemp != null && map.value < ambientTemp) {
runIn((dutyCyclePeriod * 3) / 2 as int, updateOperatingState, [overwrite: true])
}
handleOperatingStateBugfix(map.value, null)
}
} else if (descMap.attrInt == ATTRIBUTE_SYSTEM_MODE) {
log.debug "MODE - ${descMap.value}"
Expand Down Expand Up @@ -362,11 +353,29 @@ def handleTemperature(descMap) {
log.debug "CLEAR ALARM @ $map.value $map.unit (raw $intVal)"
sendEvent(name: "temperatureAlarm", value: "cleared")
}

handleOperatingStateBugfix(null, map.value)
}

map
}

// Due to a bug in this model's firmware, sometimes we don't get
// an updated operating state; so we will force it.
// TODO: Find and add firmware version check
def handleOperatingStateBugfix(setpoint, temp) {
def currSetpoint = (setpoint != null) ? setpoint : device.currentValue("heatingSetpoint")
def ambientTemp = (temp != null) ? temp : device.currentValue("temperature")

if (currSetpoint != null && ambientTemp != null) {
if (currSetpoint <= ambientTemp) {
sendEvent(name: "thermostatOperatingState", value: "idle")
} else {
sendEvent(name: "thermostatOperatingState", value: "heating")
}
}
}

def updateWeather() {
log.debug "updating weather"
def weather
Expand Down Expand Up @@ -399,10 +408,6 @@ def scheduledUpdateWeather() {
}
}

def updateOperatingState() {
sendHubCommand(zigbee.readAttribute(THERMOSTAT_CLUSTER, ATTRIBUTE_PI_HEATING_STATE))
}

/**
* PING is used by Device-Watch in attempt to reach the Device
**/
Expand Down

0 comments on commit f78b14b

Please sign in to comment.