mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 11:33:11 -04:00
Use the action field enums in midea (#195975)
This commit is contained in:
@@ -11,7 +11,6 @@ from midealocal.devices.cf import DeviceAttributes as CFAttributes, MideaCFDevic
|
||||
from midealocal.devices.fb import DeviceAttributes as FBAttributes, MideaFBDevice
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_HVAC_MODE,
|
||||
FAN_AUTO,
|
||||
FAN_HIGH,
|
||||
FAN_LOW,
|
||||
@@ -30,14 +29,10 @@ from homeassistant.components.climate import (
|
||||
ClimateEntity,
|
||||
ClimateEntityDescription,
|
||||
ClimateEntityFeature,
|
||||
ClimateServiceArgument,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
PRECISION_HALVES,
|
||||
PRECISION_WHOLE,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.const import PRECISION_HALVES, PRECISION_WHOLE, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
@@ -246,10 +241,10 @@ class MideaClimate(MideaEntity, ClimateEntity):
|
||||
@override
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Midea Climate set temperature."""
|
||||
if ATTR_TEMPERATURE not in kwargs:
|
||||
if ClimateServiceArgument.TEMPERATURE not in kwargs:
|
||||
return
|
||||
temperature = kwargs[ATTR_TEMPERATURE]
|
||||
hvac_mode = kwargs.get(ATTR_HVAC_MODE)
|
||||
temperature = kwargs[ClimateServiceArgument.TEMPERATURE]
|
||||
hvac_mode = kwargs.get(ClimateServiceArgument.HVAC_MODE)
|
||||
if hvac_mode == HVACMode.OFF:
|
||||
await self.async_turn_off()
|
||||
else:
|
||||
@@ -745,7 +740,7 @@ class MideaFBClimate(MideaClimate):
|
||||
@override
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Midea FB Climate set temperature."""
|
||||
wants_heat = kwargs.get(ATTR_HVAC_MODE) == HVACMode.HEAT
|
||||
wants_heat = kwargs.get(ClimateServiceArgument.HVAC_MODE) == HVACMode.HEAT
|
||||
if wants_heat and self.hvac_mode == HVACMode.OFF:
|
||||
await self.async_turn_on()
|
||||
await super().async_set_temperature(**kwargs)
|
||||
|
||||
@@ -7,14 +7,12 @@ from midealocal.const import DeviceType
|
||||
from midealocal.devices.x13 import Midea13Device
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP_KELVIN,
|
||||
ATTR_EFFECT,
|
||||
EFFECT_OFF,
|
||||
ColorMode,
|
||||
LightEntity,
|
||||
LightEntityDescription,
|
||||
LightEntityFeature,
|
||||
LightServiceArgument,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
@@ -145,16 +143,17 @@ class MideaLight(MideaEntity, LightEntity):
|
||||
with midea_api_call():
|
||||
if not self.is_on:
|
||||
self._device.set_attribute(attr="power", value=True)
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
if LightServiceArgument.BRIGHTNESS in kwargs:
|
||||
self._device.set_attribute(
|
||||
attr="brightness", value=kwargs[ATTR_BRIGHTNESS]
|
||||
attr="brightness", value=kwargs[LightServiceArgument.BRIGHTNESS]
|
||||
)
|
||||
if ATTR_COLOR_TEMP_KELVIN in kwargs:
|
||||
if LightServiceArgument.COLOR_TEMP_KELVIN in kwargs:
|
||||
self._device.set_attribute(
|
||||
attr="color_temperature", value=kwargs[ATTR_COLOR_TEMP_KELVIN]
|
||||
attr="color_temperature",
|
||||
value=kwargs[LightServiceArgument.COLOR_TEMP_KELVIN],
|
||||
)
|
||||
if ATTR_EFFECT in kwargs:
|
||||
effect = kwargs[ATTR_EFFECT]
|
||||
if LightServiceArgument.EFFECT in kwargs:
|
||||
effect = kwargs[LightServiceArgument.EFFECT]
|
||||
self._device.set_attribute(
|
||||
attr="effect",
|
||||
value="none" if effect == EFFECT_OFF else effect,
|
||||
|
||||
Reference in New Issue
Block a user