Skip to content

Commit

Permalink
Merge branch 'release/2024.8.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi committed Aug 9, 2024
2 parents 20fd372 + 122d05f commit 2fdc325
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 31 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .hound.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python:
enabled: true
config_file: .flake8.ini
config_file: .flake8
18 changes: 13 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
hooks:
- id: ruff
args:
- --fix
- id: ruff-format

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings, flake8-bugbear, flake8-builtins, flake8-print, flake8-pytest-style, flake8-return, flake8-simplify, flake8-annotations]
47 changes: 23 additions & 24 deletions custom_components/xiaomi_miio_airconditioningcompanion/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/climate.xiaomi_miio
"""

import asyncio
import enum
import logging
Expand All @@ -16,15 +17,8 @@
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
from homeassistant.components.climate.const import (
ATTR_HVAC_MODE,
HVAC_MODE_AUTO,
HVAC_MODE_COOL,
HVAC_MODE_DRY,
HVAC_MODE_FAN_ONLY,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
SUPPORT_FAN_MODE,
SUPPORT_SWING_MODE,
SUPPORT_TARGET_TEMPERATURE,
ClimateEntityFeature,
HVACMode,
)
from homeassistant.components.remote import (
ATTR_DELAY_SECS,
Expand All @@ -41,7 +35,7 @@
CONF_TIMEOUT,
CONF_TOKEN,
STATE_ON,
TEMP_CELSIUS,
UnitOfTemperature,
)
from homeassistant.core import callback
from homeassistant.exceptions import PlatformNotReady
Expand All @@ -66,7 +60,11 @@
ATTR_LOAD_POWER = "load_power"
ATTR_LED = "led"

SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE | SUPPORT_SWING_MODE
SUPPORT_FLAGS = (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.FAN_MODE
| ClimateEntityFeature.SWING_MODE
)

CONF_SENSOR = "target_sensor"
CONF_MIN_TEMP = "min_temp"
Expand Down Expand Up @@ -205,12 +203,12 @@ async def async_service_handler(service):


class OperationMode(enum.Enum):
Heat = HVAC_MODE_HEAT
Cool = HVAC_MODE_COOL
Auto = HVAC_MODE_AUTO
Dehumidify = HVAC_MODE_DRY
Ventilate = HVAC_MODE_FAN_ONLY
Off = HVAC_MODE_OFF
Heat = HVACMode.HEAT
Cool = HVACMode.COOL
Auto = HVACMode.AUTO
Dehumidify = HVACMode.DRY
Ventilate = HVACMode.FAN_ONLY
Off = HVACMode.OFF


class XiaomiAirConditioningCompanion(ClimateEntity):
Expand All @@ -227,7 +225,6 @@ def __init__(
min_temp,
max_temp,
):

"""Initialize the climate device."""
self.hass = hass
self._name = name
Expand Down Expand Up @@ -364,7 +361,7 @@ async def async_update(self):
)
self._last_on_operation = OperationMode[state.mode.name].value
if state.power == "off":
self._hvac_mode = HVAC_MODE_OFF
self._hvac_mode = HVACMode.OFF
self._state = False
else:
self._hvac_mode = self._last_on_operation
Expand Down Expand Up @@ -427,7 +424,7 @@ def extra_state_attributes(self):
@property
def temperature_unit(self):
"""Return the unit of measurement."""
return TEMP_CELSIUS
return UnitOfTemperature.CELSIUS

@property
def current_temperature(self):
Expand Down Expand Up @@ -497,7 +494,7 @@ async def async_set_hvac_mode(self, hvac_mode):
)
if result:
self._state = False
self._hvac_mode = HVAC_MODE_OFF
self._hvac_mode = HVACMode.OFF
await self._send_configuration()
else:
self._hvac_mode = OperationMode(hvac_mode).value
Expand Down Expand Up @@ -527,9 +524,11 @@ async def _send_configuration(self):
self._device.send_configuration,
self._air_condition_model,
Power(int(self._state)),
MiioOperationMode[OperationMode(self._hvac_mode).name]
if self._state
else MiioOperationMode[OperationMode(self._last_on_operation).name],
(
MiioOperationMode[OperationMode(self._hvac_mode).name]
if self._state
else MiioOperationMode[OperationMode(self._last_on_operation).name]
),
int(self._target_temperature),
self._fan_mode,
self._swing_mode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"construct==2.10.68",
"python-miio>=0.5.12"
],
"version": "2023.12.0.0"
"version": "2024.8.0.0"
}

0 comments on commit 2fdc325

Please sign in to comment.