diff --git a/custom_components/gree/climate.py b/custom_components/gree/climate.py index 77d53de..26f8673 100644 --- a/custom_components/gree/climate.py +++ b/custom_components/gree/climate.py @@ -87,8 +87,7 @@ vol.Optional(CONF_UID): cv.positive_int }) -@asyncio.coroutine -def async_setup_platform(hass, config, async_add_devices, discovery_info=None): +async def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.info('Setting up Gree climate platform') name = config.get(CONF_NAME) ip_addr = config.get(CONF_HOST) @@ -458,14 +457,14 @@ def SyncState(self, acOptions = {}): _LOGGER.info('Finished SyncState') return receivedJsonPayload - @asyncio.coroutine - def _async_temp_sensor_changed(self, entity_id, old_state, new_state): + async def _async_temp_sensor_changed(self, entity_id, old_state, new_state): _LOGGER.info('temp_sensor state changed |' + str(entity_id) + '|' + str(old_state) + '|' + str(new_state)) # Handle temperature changes. if new_state is None: return self._async_update_current_temp(new_state) - yield from self.async_update_ha_state() + for x in self.async_update_ha_state(): + yield x @callback def _async_update_current_temp(self, state): @@ -489,8 +488,7 @@ def represents_float(self, s): except ValueError: return False - @asyncio.coroutine - def _async_lights_entity_state_changed(self, entity_id, old_state, new_state): + async def _async_lights_entity_state_changed(self, entity_id, old_state, new_state): _LOGGER.info('lights_entity state changed |' + str(entity_id) + '|' + str(old_state) + '|' + str(new_state)) if new_state is None: return @@ -498,7 +496,8 @@ def _async_lights_entity_state_changed(self, entity_id, old_state, new_state): # do nothing if state change is triggered due to Sync with HVAC return self._async_update_current_lights(new_state) - yield from self.async_update_ha_state() + for x in self.async_update_ha_state(): + yield x @callback def _async_update_current_lights(self, state): @@ -511,8 +510,7 @@ def _async_update_current_lights(self, state): return _LOGGER.error('Unable to update from lights_entity!') - @asyncio.coroutine - def _async_xfan_entity_state_changed(self, entity_id, old_state, new_state): + async def _async_xfan_entity_state_changed(self, entity_id, old_state, new_state): _LOGGER.info('xfan_entity state changed |' + str(entity_id) + '|' + str(old_state) + '|' + str(new_state)) if new_state is None: return @@ -524,7 +522,8 @@ def _async_xfan_entity_state_changed(self, entity_id, old_state, new_state): _LOGGER.info('Cant set xfan in %s mode' % str(self._hvac_mode)) return self._async_update_current_xfan(new_state) - yield from self.async_update_ha_state() + for x in self.async_update_ha_state(): + yield x @callback def _async_update_current_xfan(self, state): @@ -537,8 +536,7 @@ def _async_update_current_xfan(self, state): return _LOGGER.error('Unable to update from xfan_entity!') - @asyncio.coroutine - def _async_health_entity_state_changed(self, entity_id, old_state, new_state): + async def _async_health_entity_state_changed(self, entity_id, old_state, new_state): _LOGGER.info('health_entity state changed |' + str(entity_id) + '|' + str(old_state) + '|' + str(new_state)) if new_state is None: return @@ -546,7 +544,8 @@ def _async_health_entity_state_changed(self, entity_id, old_state, new_state): # do nothing if state change is triggered due to Sync with HVAC return self._async_update_current_health(new_state) - yield from self.async_update_ha_state() + for x in self.async_update_ha_state(): + yield x @callback def _async_update_current_health(self, state): @@ -559,8 +558,7 @@ def _async_update_current_health(self, state): return _LOGGER.error('Unable to update from health_entity!') - @asyncio.coroutine - def _async_powersave_entity_state_changed(self, entity_id, old_state, new_state): + async def _async_powersave_entity_state_changed(self, entity_id, old_state, new_state): _LOGGER.info('powersave_entity state changed |' + str(entity_id) + '|' + str(old_state) + '|' + str(new_state)) if new_state is None: return @@ -572,7 +570,8 @@ def _async_powersave_entity_state_changed(self, entity_id, old_state, new_state) _LOGGER.info('Cant set powersave in %s mode' % str(self._hvac_mode)) return self._async_update_current_powersave(new_state) - yield from self.async_update_ha_state() + for x in self.async_update_ha_state(): + yield x @callback def _async_update_current_powersave(self, state): @@ -586,8 +585,7 @@ def _async_update_current_powersave(self, state): _LOGGER.error('Unable to update from powersave_entity!') - @asyncio.coroutine - def _async_sleep_entity_state_changed(self, entity_id, old_state, new_state): + async def _async_sleep_entity_state_changed(self, entity_id, old_state, new_state): _LOGGER.info('sleep_entity state changed |' + str(entity_id) + '|' + str(old_state) + '|' + str(new_state)) if new_state is None: return @@ -599,7 +597,8 @@ def _async_sleep_entity_state_changed(self, entity_id, old_state, new_state): _LOGGER.info('Cant set sleep in %s mode' % str(self._hvac_mode)) return self._async_update_current_sleep(new_state) - yield from self.async_update_ha_state() + for x in self.async_update_ha_state(): + yield x @callback def _async_update_current_sleep(self, state): @@ -612,8 +611,7 @@ def _async_update_current_sleep(self, state): return _LOGGER.error('Unable to update from sleep_entity!') - @asyncio.coroutine - def _async_eightdegheat_entity_state_changed(self, entity_id, old_state, new_state): + async def _async_eightdegheat_entity_state_changed(self, entity_id, old_state, new_state): _LOGGER.info('eightdegheat_entity state changed |' + str(entity_id) + '|' + str(old_state) + '|' + str(new_state)) if new_state is None: return @@ -625,7 +623,8 @@ def _async_eightdegheat_entity_state_changed(self, entity_id, old_state, new_sta _LOGGER.info('Cant set 8℃ heat in %s mode' % str(self._hvac_mode)) return self._async_update_current_eightdegheat(new_state) - yield from self.async_update_ha_state() + for x in self.async_update_ha_state(): + yield x @callback def _async_update_current_eightdegheat(self, state): @@ -638,8 +637,7 @@ def _async_update_current_eightdegheat(self, state): return _LOGGER.error('Unable to update from eightdegheat_entity!') - @asyncio.coroutine - def _async_air_entity_state_changed(self, entity_id, old_state, new_state): + async def _async_air_entity_state_changed(self, entity_id, old_state, new_state): _LOGGER.info('air_entity state changed |' + str(entity_id) + '|' + str(old_state) + '|' + str(new_state)) if new_state is None: return @@ -647,7 +645,8 @@ def _async_air_entity_state_changed(self, entity_id, old_state, new_state): # do nothing if state change is triggered due to Sync with HVAC return self._async_update_current_air(new_state) - yield from self.async_update_ha_state() + for x in self.async_update_ha_state(): + yield x @callback def _async_update_current_air(self, state): @@ -801,8 +800,7 @@ def set_hvac_mode(self, hvac_mode): self.SyncState({'Mod': self._hvac_modes.index(hvac_mode), 'Pow': 1}) self.schedule_update_ha_state() - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): _LOGGER.info('Gree climate device added to hass()') self.SyncState()