44 * Author: Zen Within
55 * Date: 2015-02-21
66 * Updated by SmartThings
7- * Date: 2017-09-07
7+ * Date: 2017-10-12
88 */
99metadata {
1010 definition (name : " Zen Thermostat" , namespace : " zenwithin" , author : " ZenWithin" ) {
@@ -196,7 +196,6 @@ def parse(String description) {
196196 def mode = device. currentValue(" thermostatMode" )
197197 switch (descMap. attrId) {
198198 case " 0000" : // ATTRIBUTE_LOCAL_TEMPERATURE
199- log. debug " LOCAL TEMPERATURE"
200199 map. name = " temperature"
201200 map. unit = locationScale
202201 map. value = getTempInLocalScale(parseTemperature(descMap. value), " C" ) // Zibee always reports in °C
@@ -251,7 +250,11 @@ def parse(String description) {
251250 case " 001c" : // ATTRIBUTE_SYSTEM_MODE
252251 // Make sure operating state is in sync
253252 map. name = " thermostatMode"
254- map. isStateChange = true // set to true to force update if switchMode failed and old mode is returned
253+ if (state. switchMode) {
254+ // set isStateChange to true to force update if switchMode failed and old mode is returned
255+ map. isStateChange = true
256+ state. switchMode = false
257+ }
255258 map. data = [supportedThermostatModes : supportedModes]
256259 map. value = systemModeMap[descMap. value]
257260 // in case of refresh, allow heat/cool setpoints to be reported before updating setpoint
@@ -275,7 +278,11 @@ def parse(String description) {
275278 // Make sure operating state is in sync
276279 ping()
277280 map. name = " thermostatFanMode"
278- map. isStateChange = true // set to true to force update if switchMode failed and old mode is returned
281+ if (state. switchFanMode) {
282+ // set isStateChange to true to force update if switchMode failed and old mode is returned
283+ map. isStateChange = true
284+ state. switchFanMode = false
285+ }
279286 map. data = [supportedThermostatFanModes : state. supportedFanModes]
280287 map. value = fanModeMap[descMap. value]
281288 break
@@ -296,7 +303,6 @@ def parse(String description) {
296303 if (map) {
297304 result = createEvent(map)
298305 }
299- log. debug " Parse returned $map , result:$result "
300306 return result
301307}
302308
@@ -407,9 +413,9 @@ def updateBatteryStatus(rawValue) {
407413 // customAttribute in order to change UI icon/label
408414 def eventMap = [name : " batteryIcon" , value : " err_battery" , displayed : false ]
409415 def linkText = getLinkText(device)
410- if (volts < 61 && volts != 0 && volts != 255 ) {
416+ if (volts < 62 && volts != 0 && volts != 255 ) {
411417 def minVolts = 34 // voltage when device UI starts to die
412- def maxVolts = 60 // 4 batteries at 1.5V
418+ def maxVolts = 61 // 4 batteries at 1.5V should be 6.0V, however logs from users show 6,1 as well
413419 def pct = (volts - minVolts) / (maxVolts - minVolts)
414420 eventMap. value = Math . min(100 , (int ) pct * 100 )
415421 // Update capability "Battery"
@@ -664,6 +670,7 @@ def switchToMode(nextMode) {
664670 def mode = Integer . parseInt(systemModeMap. find { it. value == nextMode }?. key, 16 )
665671 cmds + = zigbee. writeAttribute(THERMOSTAT_CLUSTER , ATTRIBUTE_SYSTEM_MODE , typeENUM8, mode)
666672 sendZigbeeCmds(cmds)
673+ state. switchMode = true
667674 } else {
668675 log. debug(" ThermostatMode $nextMode is not supported by ${ device.displayName} " )
669676 }
@@ -712,6 +719,7 @@ def switchToFanMode(nextMode) {
712719 def mode = fanModeMap. find { it. value == nextMode }?. key
713720 def cmds = zigbee. writeAttribute(FAN_CONTROL_CLUSTER , ATTRIBUTE_FAN_MODE , typeENUM8, mode)
714721 sendZigbeeCmds(cmds)
722+ state. switchFanMode = true
715723 } else {
716724 log. debug(" FanMode $nextMode is not supported by ${ device.displayName} " )
717725 }
0 commit comments