This commit is contained in:
Home Assistant Version Control
2026-08-12 23:21:24 +00:00
parent 4517d1682f
commit f8ab9eda84
24 changed files with 625 additions and 468 deletions
+16 -10
View File
@@ -12,15 +12,15 @@ from homeassistant.const import (
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from midealocal.device import DeviceType
from midealocal.devices.ac import DeviceAttributes as ACAttributes
from midealocal.devices.ac import MideaACDevice
from midealocal.devices.b6 import MideaB6Device
from midealocal.devices.ce import DeviceAttributes as CEAttributes
from midealocal.devices.ce import MideaCEDevice
from midealocal.devices.fa import MideaFADevice
from midealocal.devices.x40 import DeviceAttributes as X40Attributes
from midealocal.devices.x40 import MideaX40Device
from midealan.device import DeviceType
from midealan.devices.ac import DeviceAttributes as ACAttributes
from midealan.devices.ac import MideaACDevice
from midealan.devices.b6 import MideaB6Device
from midealan.devices.ce import DeviceAttributes as CEAttributes
from midealan.devices.ce import MideaCEDevice
from midealan.devices.fa import MideaFADevice
from midealan.devices.x40 import DeviceAttributes as X40Attributes
from midealan.devices.x40 import MideaX40Device
from .const import DEVICES, DOMAIN
from .midea_devices import (
@@ -122,7 +122,13 @@ class MideaFan(MideaEntity, FanEntity):
def set_preset_mode(self, preset_mode: str) -> None:
"""Midea Fan set preset mode."""
self._device.set_attribute(attr="mode", value=preset_mode.capitalize())
# Pass the preset value through unchanged. `preset_modes` already
# returns the device's own strings and HA only ever hands one of them
# back, so the value is guaranteed valid. Do NOT `.capitalize()` it:
# that corrupts multi-word / mixed-case names such as the CE fan's
# "ECO mode" -> "Eco mode", which the device matches case-sensitively
# and silently drops, making the ECO preset unselectable.
self._device.set_attribute(attr="mode", value=preset_mode)
@property
def percentage(self) -> int | None: