From 0ab30b6a9f63e08f1fff9dd1190be86478a39abd Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Thu, 8 Jun 2023 10:14:07 +0200 Subject: [PATCH 1/2] Add missing async statements --- .../climate.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/custom_components/xiaomi_miio_airconditioningcompanion/climate.py b/custom_components/xiaomi_miio_airconditioningcompanion/climate.py index 2472e48..ef5c43d 100644 --- a/custom_components/xiaomi_miio_airconditioningcompanion/climate.py +++ b/custom_components/xiaomi_miio_airconditioningcompanion/climate.py @@ -126,7 +126,7 @@ # pylint: disable=unused-argument -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): """Set up the air conditioning companion from config.""" from miio import AirConditioningCompanion, DeviceException @@ -296,20 +296,20 @@ def _async_update_power_state(self, state): else: yield from self.async_turn_off() - def _async_sensor_changed(self, entity_id, old_state, new_state): + async def _async_sensor_changed(self, entity_id, old_state, new_state): """Handle temperature changes.""" if new_state is None: return self._async_update_temp(new_state) - def _async_power_sensor_changed(self, entity_id, old_state, new_state): + async def _async_power_sensor_changed(self, entity_id, old_state, new_state): """Handle power sensor changes.""" if new_state is None: return yield from self._async_update_power_state(new_state) - def _try_command(self, mask_error, func, *args, **kwargs): + async def _try_command(self, mask_error, func, *args, **kwargs): """Call a AC companion command handling error messages.""" from miio import DeviceException @@ -324,7 +324,7 @@ def _try_command(self, mask_error, func, *args, **kwargs): self._available = False return False - def async_turn_on(self, speed: str = None, **kwargs) -> None: + async def async_turn_on(self, speed: str = None, **kwargs) -> None: """Turn the miio device on.""" result = yield from self._try_command( "Turning the miio device on failed.", self._device.on @@ -333,7 +333,7 @@ def async_turn_on(self, speed: str = None, **kwargs) -> None: if result: self._state = True - def async_turn_off(self, **kwargs) -> None: + async def async_turn_off(self, **kwargs) -> None: """Turn the miio device off.""" result = yield from self._try_command( "Turning the miio device off failed.", self._device.off @@ -342,7 +342,7 @@ def async_turn_off(self, **kwargs) -> None: if result: self._state = False - def async_update(self): + async def async_update(self): """Update the state of this climate device.""" from miio import DeviceException @@ -466,7 +466,7 @@ def fan_modes(self): return [speed.name.lower() for speed in FanSpeed] - def async_set_temperature(self, **kwargs): + async def async_set_temperature(self, **kwargs): """Set target temperature.""" if kwargs.get(ATTR_TEMPERATURE) is not None: self._target_temperature = kwargs.get(ATTR_TEMPERATURE) @@ -475,21 +475,21 @@ def async_set_temperature(self, **kwargs): yield from self._send_configuration() - def async_set_swing_mode(self, swing_mode): + async def async_set_swing_mode(self, swing_mode): """Set the swing mode.""" from miio.airconditioningcompanion import SwingMode self._swing_mode = SwingMode[swing_mode.title()] yield from self._send_configuration() - def async_set_fan_mode(self, fan_mode): + async def async_set_fan_mode(self, fan_mode): """Set the fan mode.""" from miio.airconditioningcompanion import FanSpeed self._fan_mode = FanSpeed[fan_mode.title()] yield from self._send_configuration() - def async_set_hvac_mode(self, hvac_mode): + async def async_set_hvac_mode(self, hvac_mode): """Set new target hvac mode.""" if hvac_mode == OperationMode.Off.value: result = yield from self._try_command( @@ -516,7 +516,7 @@ def swing_modes(self): return [mode.name.lower() for mode in SwingMode] - def _send_configuration(self): + async def _send_configuration(self): from miio.airconditioningcompanion import Led from miio.airconditioningcompanion import OperationMode as MiioOperationMode from miio.airconditioningcompanion import Power @@ -541,7 +541,7 @@ def _send_configuration(self): "Configuration cannot be sent." ) - def async_learn_command(self, slot, timeout): + async def async_learn_command(self, slot, timeout): """Learn a infrared command.""" yield from self.hass.async_add_job(self._device.learn, slot) @@ -569,7 +569,7 @@ def async_learn_command(self, slot, timeout): "Timeout. No infrared command captured", title="Xiaomi Miio Remote" ) - def async_send_command(self, command, **kwargs): + async def async_send_command(self, command, **kwargs): """Send a infrared command.""" repeat = kwargs[ATTR_NUM_REPEATS] delay = kwargs[ATTR_DELAY_SECS] From 8c395af51f1bb6ee5c63b01128e73ecc32c8106a Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Thu, 8 Jun 2023 10:15:48 +0200 Subject: [PATCH 2/2] Bump custom component version --- .../xiaomi_miio_airconditioningcompanion/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/xiaomi_miio_airconditioningcompanion/manifest.json b/custom_components/xiaomi_miio_airconditioningcompanion/manifest.json index 15a8473..e2edd71 100644 --- a/custom_components/xiaomi_miio_airconditioningcompanion/manifest.json +++ b/custom_components/xiaomi_miio_airconditioningcompanion/manifest.json @@ -13,5 +13,5 @@ "construct==2.10.56", "python-miio>=0.5.12" ], - "version": "2023.6.0.0" + "version": "2023.6.0.1" }