diff --git a/custom_components/gree/climate.py b/custom_components/gree/climate.py index 28818a8..9c7a4d5 100644 --- a/custom_components/gree/climate.py +++ b/custom_components/gree/climate.py @@ -1,4 +1,4 @@ -""" +/""" Gree Climate Entity for Home Assistant. This module defines the climate (HVAC) unit for the Gree integration. @@ -273,8 +273,8 @@ async def GreeGetValues(self, propertyNames): jsonPayloadToSend = '{"cid":"app","i":0,"pack":"' + pack + '","t":"pack","tcid":"' + str(self._mac_addr) + '","uid":{}'.format(self._uid) + ',"tag" : "' + tag + '"}' cipher = GetGCMCipher(self._encryption_key) result = await FetchResult(cipher, self._ip_addr, self._port, jsonPayloadToSend, encryption_version=self.encryption_version) - return result["dat"][0] if len(result["dat"]) == 1 else result["dat"] - + return None if len(result["dat"]) == 0 else result["dat"][0] if len(result["dat"]) == 1 else result["dat"] + def SetAcOptions(self, acOptions, newOptionsToOverride, optionValuesToOverride=None): if optionValuesToOverride is not None: # Build a list of key-value pairs for a single log line @@ -511,7 +511,7 @@ async def SyncState(self, acOptions={}): except Exception: _LOGGER.debug("Could not determine whether device has an built-in temperature sensor. Retrying at next update()") else: - if temp_sensor: + if temp_sensor is not None: self._has_temp_sensor = True self._acOptions.update({"TemSen": None}) self._optionsToFetch.append("TemSen") @@ -528,7 +528,7 @@ async def SyncState(self, acOptions={}): except Exception: _LOGGER.debug("Could not determine whether device has an anti direct blow feature. Retrying at next update()") else: - if anti_direct_blow: + if anti_direct_blow is not None: self._has_anti_direct_blow = True self._acOptions.update({"AntiDirectBlow": None}) self._optionsToFetch.append("AntiDirectBlow") @@ -545,7 +545,7 @@ async def SyncState(self, acOptions={}): except Exception: _LOGGER.debug("Could not determine whether device has a built-in light sensor. Retrying at next update()") else: - if light_sensor: + if light_sensor is not None: self._has_light_sensor = True self._acOptions.update({"LigSen": None}) self._optionsToFetch.append("LigSen") @@ -562,7 +562,7 @@ async def SyncState(self, acOptions={}): except Exception: _LOGGER.debug("Could not determine whether device has an outside temperature sensor. Retrying at next update()") else: - if outside_temp_sensor: + if outside_temp_sensor is not None: self._has_outside_temp_sensor = True self._acOptions.update({"OutEnvTem": None}) self._optionsToFetch.append("OutEnvTem") @@ -579,7 +579,7 @@ async def SyncState(self, acOptions={}): except Exception: _LOGGER.debug("Could not determine whether device has a room humidity sensor. Retrying at next update()") else: - if humidity_sensor: + if humidity_sensor is not None: self._has_room_humidity_sensor = True self._acOptions.update({"DwatSen": None}) self._optionsToFetch.append("DwatSen")