Skip to content

Commit

Permalink
2023.6 Compatibility (Python 3.11)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobHofmann authored Jun 4, 2023
1 parent 7947b7f commit 896d911
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions custom_components/gree/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -489,16 +488,16 @@ 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
if new_state.state is self._current_lights:
# 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):
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -537,16 +536,16 @@ 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
if new_state.state is self._current_health:
# 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):
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -638,16 +637,16 @@ 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
if new_state.state is self._current_air:
# 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):
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 896d911

Please sign in to comment.