diff --git a/README.md b/README.md index 8ddc66d..68cebf9 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Name | Default | Description :--- | :--- | :--- **Beep** | True | Enable beep on setting changes. **Temperature Step** | 1.0 | Step size for temperature set point. +**Fan Speed Step** | 1 | Step size for custom fan speeds. **Use Fan-only Workaround** | False | Enable this option if device updates cause the device to turn on and switch to fan-only. **Show All Presets** | False | Show all presets regardless of device's reported capabilities. **Additional Operation Modes** | Empty | Additional HVAC modes to make available in case the device's capabilities are incorrect. diff --git a/custom_components/midea_ac/config_flow.py b/custom_components/midea_ac/config_flow.py index 450b151..8dd0e9b 100644 --- a/custom_components/midea_ac/config_flow.py +++ b/custom_components/midea_ac/config_flow.py @@ -14,7 +14,8 @@ from msmart.discover import Discover from msmart.lan import AuthenticationError -from .const import (CONF_ADDITIONAL_OPERATION_MODES, CONF_BEEP, CONF_KEY, +from .const import (CONF_ADDITIONAL_OPERATION_MODES, CONF_BEEP, + CONF_FAN_SPEED_STEP, CONF_KEY, CONF_MAX_CONNECTION_LIFETIME, CONF_SHOW_ALL_PRESETS, CONF_TEMP_STEP, CONF_USE_ALTERNATE_ENERGY_FORMAT, CONF_USE_FAN_ONLY_WORKAROUND, DOMAIN) @@ -22,6 +23,7 @@ _DEFAULT_OPTIONS = { CONF_BEEP: True, CONF_TEMP_STEP: 1.0, + CONF_FAN_SPEED_STEP: 1, CONF_USE_FAN_ONLY_WORKAROUND: False, CONF_SHOW_ALL_PRESETS: False, CONF_ADDITIONAL_OPERATION_MODES: None, @@ -232,6 +234,8 @@ async def async_step_init(self, user_input=None) -> FlowResult: default=options.get(CONF_BEEP, True)): cv.boolean, vol.Optional(CONF_TEMP_STEP, default=options.get(CONF_TEMP_STEP, 1.0)): vol.All(vol.Coerce(float), vol.Range(min=0.5, max=5)), + vol.Optional(CONF_FAN_SPEED_STEP, + default=options.get(CONF_FAN_SPEED_STEP, 1)): vol.All(vol.Coerce(float), vol.Range(min=1, max=20)), vol.Optional(CONF_USE_FAN_ONLY_WORKAROUND, default=options.get(CONF_USE_FAN_ONLY_WORKAROUND, False)): cv.boolean, vol.Optional(CONF_SHOW_ALL_PRESETS, diff --git a/custom_components/midea_ac/const.py b/custom_components/midea_ac/const.py index cd244b6..00bce68 100644 --- a/custom_components/midea_ac/const.py +++ b/custom_components/midea_ac/const.py @@ -3,6 +3,7 @@ CONF_KEY = "k1" CONF_BEEP = "prompt_tone" CONF_TEMP_STEP = "temp_step" +CONF_FAN_SPEED_STEP = "fan_speed_step" CONF_USE_FAN_ONLY_WORKAROUND = "use_fan_only_workaround" CONF_ADDITIONAL_OPERATION_MODES = "additional_operation_modes" CONF_SHOW_ALL_PRESETS = "show_all_presets" diff --git a/custom_components/midea_ac/number.py b/custom_components/midea_ac/number.py index d921880..b614364 100644 --- a/custom_components/midea_ac/number.py +++ b/custom_components/midea_ac/number.py @@ -10,7 +10,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from msmart.device import AirConditioner as AC -from .const import DOMAIN +from .const import CONF_FAN_SPEED_STEP, DOMAIN from .coordinator import MideaCoordinatorEntity, MideaDeviceUpdateCoordinator _LOGGER = logging.getLogger(__name__) @@ -30,7 +30,10 @@ async def async_setup_entry( # Create entity if supported if coordinator.device.supports_custom_fan_speed: - add_entities([MideaFanSpeedNumber(coordinator)]) + add_entities([MideaFanSpeedNumber( + coordinator, + config_entry.options.get(CONF_FAN_SPEED_STEP, 1) + )]) class MideaFanSpeedNumber(MideaCoordinatorEntity, NumberEntity): @@ -38,9 +41,14 @@ class MideaFanSpeedNumber(MideaCoordinatorEntity, NumberEntity): _attr_translation_key = "fan_speed" - def __init__(self, coordinator: MideaDeviceUpdateCoordinator) -> None: + def __init__(self, + coordinator: MideaDeviceUpdateCoordinator, + step_size: float = 1 + ) -> None: MideaCoordinatorEntity.__init__(self, coordinator) + self._step_size = step_size + @property def device_info(self) -> dict: """Return info for device registry.""" @@ -75,7 +83,12 @@ def native_max_value(self) -> float: @property def native_min_value(self) -> float: - return 1 + # Use step size as minimum to ensure steps are nice and round + return self._step_size + + @property + def native_step(self) -> float: + return self._step_size @property def native_value(self) -> float: diff --git a/custom_components/midea_ac/translations/en.json b/custom_components/midea_ac/translations/en.json index e80c4d1..55032ae 100644 --- a/custom_components/midea_ac/translations/en.json +++ b/custom_components/midea_ac/translations/en.json @@ -46,6 +46,7 @@ "data": { "prompt_tone": "Enable Beep", "temp_step": "Temperature Step", + "fan_speed_step": "Fan Speed Step", "use_fan_only_workaround": "Use Fan-only Workaround", "show_all_presets": "Show All Presets", "additional_operation_modes": "Additional Operation Modes", @@ -54,6 +55,7 @@ }, "data_description": { "temp_step": "Step size for temperature set point", + "fan_speed_step": "Step size for custom fan speeds", "additional_operation_modes": "Specify additional operational modes", "max_connection_lifetime": "Maximum time in seconds a connection will be used (30 second minimum)" }