diff --git a/homeassistant/components/intelliclima/fan.py b/homeassistant/components/intelliclima/fan.py index b0ec494e184..28b64e1d768 100644 --- a/homeassistant/components/intelliclima/fan.py +++ b/homeassistant/components/intelliclima/fan.py @@ -74,7 +74,7 @@ class IntelliClimaVMCFan(IntelliClimaECOEntity, FanEntity): """Return the current speed percentage.""" device_data = self._device_data - if device_data.speed_set == FanSpeed.auto: + if device_data.speed_set == FanSpeed.auto_get: return None return ranged_value_to_percentage(self._speed_range, int(device_data.speed_set)) @@ -92,7 +92,7 @@ class IntelliClimaVMCFan(IntelliClimaECOEntity, FanEntity): if device_data.mode_set == FanMode.off: return None if ( - device_data.speed_set == FanSpeed.auto + device_data.speed_set == FanSpeed.auto_get and device_data.mode_set == FanMode.sensor ): return "auto" @@ -111,7 +111,7 @@ class IntelliClimaVMCFan(IntelliClimaECOEntity, FanEntity): infinitely. """ percentage = 25 if percentage == 0 else percentage - await self.async_set_mode_speed(fan_mode=preset_mode, percentage=percentage) + await self.async_set_mode_speed(preset_mode=preset_mode, percentage=percentage) async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the fan.""" @@ -124,10 +124,10 @@ class IntelliClimaVMCFan(IntelliClimaECOEntity, FanEntity): async def async_set_preset_mode(self, preset_mode: str) -> None: """Set preset mode.""" - await self.async_set_mode_speed(fan_mode=preset_mode) + await self.async_set_mode_speed(preset_mode=preset_mode) async def async_set_mode_speed( - self, fan_mode: str | None = None, percentage: int | None = None + self, preset_mode: str | None = None, percentage: int | None = None ) -> None: """Set mode and speed. @@ -137,7 +137,7 @@ class IntelliClimaVMCFan(IntelliClimaECOEntity, FanEntity): percentage = self.percentage if percentage is None else percentage percentage = 25 if percentage is None else percentage - if fan_mode == "auto": + if preset_mode == "auto": # auto is a special case with special mode and speed setting await self.coordinator.api.ecocomfort.set_mode_speed_auto(self._device_sn) await self.coordinator.async_request_refresh() @@ -148,21 +148,20 @@ class IntelliClimaVMCFan(IntelliClimaECOEntity, FanEntity): return # Determine the fan mode - if fan_mode is not None: - # Set to requested fan_mode - mode = fan_mode - elif not self.is_on: + if not self.is_on: # Default to alternate fan mode if not turned on mode = FanMode.alternate else: # Maintain current mode mode = self._device_data.mode_set - speed = str( - math.ceil( - percentage_to_ranged_value( - self._speed_range, - percentage, + speed = FanSpeed( + str( + math.ceil( + percentage_to_ranged_value( + self._speed_range, + percentage, + ) ) ) ) diff --git a/homeassistant/components/intelliclima/manifest.json b/homeassistant/components/intelliclima/manifest.json index 4d15d4bfa9a..97c90f65e96 100644 --- a/homeassistant/components/intelliclima/manifest.json +++ b/homeassistant/components/intelliclima/manifest.json @@ -7,5 +7,5 @@ "integration_type": "device", "iot_class": "cloud_polling", "quality_scale": "bronze", - "requirements": ["pyintelliclima==0.2.2"] + "requirements": ["pyintelliclima==0.3.1"] } diff --git a/homeassistant/components/intelliclima/select.py b/homeassistant/components/intelliclima/select.py index d6b9f23b595..02e865088fa 100644 --- a/homeassistant/components/intelliclima/select.py +++ b/homeassistant/components/intelliclima/select.py @@ -68,12 +68,12 @@ class IntelliClimaVMCFanModeSelect(IntelliClimaECOEntity, SelectEntity): # If in auto mode (sensor mode with auto speed), return None (handled by fan entity preset mode) if ( - device_data.speed_set == FanSpeed.auto + device_data.speed_set == FanSpeed.auto_get and device_data.mode_set == FanMode.sensor ): return None - return INTELLICLIMA_MODE_TO_FAN_MODE.get(FanMode(device_data.mode_set)) + return INTELLICLIMA_MODE_TO_FAN_MODE.get(device_data.mode_set) async def async_select_option(self, option: str) -> None: """Set the fan mode.""" @@ -83,7 +83,7 @@ class IntelliClimaVMCFanModeSelect(IntelliClimaECOEntity, SelectEntity): # Determine speed: keep current speed if available, otherwise default to sleep if ( - device_data.speed_set == FanSpeed.auto + device_data.speed_set == FanSpeed.auto_get or device_data.mode_set == FanMode.off ): speed = FanSpeed.sleep diff --git a/homeassistant/components/intelliclima/strings.json b/homeassistant/components/intelliclima/strings.json index 2cc00c3c371..7c8e1b25053 100644 --- a/homeassistant/components/intelliclima/strings.json +++ b/homeassistant/components/intelliclima/strings.json @@ -6,7 +6,7 @@ "error": { "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]", - "no_devices": "No IntelliClima devices found in your account", + "no_devices": "No supported IntelliClima devices were found in your account", "unknown": "[%key:common::config_flow::error::unknown%]" }, "step": { diff --git a/requirements_all.txt b/requirements_all.txt index cd173e8aa69..58782b72050 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2158,7 +2158,7 @@ pyicloud==2.4.1 pyinsteon==1.6.4 # homeassistant.components.intelliclima -pyintelliclima==0.2.2 +pyintelliclima==0.3.1 # homeassistant.components.intesishome pyintesishome==1.8.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index ddf6b100249..88d3703b6c9 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1847,7 +1847,7 @@ pyicloud==2.4.1 pyinsteon==1.6.4 # homeassistant.components.intelliclima -pyintelliclima==0.2.2 +pyintelliclima==0.3.1 # homeassistant.components.ipma pyipma==3.0.9 diff --git a/tests/components/intelliclima/conftest.py b/tests/components/intelliclima/conftest.py index 6f97e3289ef..c0925b20420 100644 --- a/tests/components/intelliclima/conftest.py +++ b/tests/components/intelliclima/conftest.py @@ -4,6 +4,7 @@ from collections.abc import Generator from types import SimpleNamespace from unittest.mock import AsyncMock, patch +from pyintelliclima.const import FanMode, FanSpeed from pyintelliclima.intelliclima_types import ( IntelliClimaDevices, IntelliClimaECO, @@ -50,9 +51,9 @@ def single_eco_device() -> IntelliClimaDevices: model=IntelliClimaModelType(modello="ECO", tipo="wifi"), name="Test VMC", houses_id="12345", - mode_set="1", + mode_set=FanMode.inward, mode_state="1", - speed_set="3", + speed_set=FanSpeed.medium, speed_state="3", last_online="2025-11-18 10:22:51", creation_date="2025-11-18 10:22:51", diff --git a/tests/components/intelliclima/test_fan.py b/tests/components/intelliclima/test_fan.py index 5319be60098..0ad99a02996 100644 --- a/tests/components/intelliclima/test_fan.py +++ b/tests/components/intelliclima/test_fan.py @@ -3,6 +3,7 @@ from collections.abc import AsyncGenerator from unittest.mock import AsyncMock, patch +from pyintelliclima.const import FanMode, FanSpeed import pytest from syrupy.assertion import SnapshotAssertion @@ -103,7 +104,7 @@ async def test_fan_turn_on_service_calls_api( # Device serial from single_eco_device.crono_sn mock_cloud_interface.ecocomfort.set_mode_speed.assert_awaited_once_with( - "11223344", "1", "2" + "11223344", FanMode.inward, FanSpeed.low ) @@ -119,10 +120,10 @@ async def test_fan_set_percentage_maps_to_speed( {ATTR_ENTITY_ID: FAN_ENTITY_ID, ATTR_PERCENTAGE: 15}, blocking=True, ) - # Initial mode_set="1" (forward) from single_eco_device. - # Sleep speed is "1" (25%). + # Initial mode_set=FanMode.inward from single_eco_device. + # Sleep speed is FanSpeed.sleep (25%). mock_cloud_interface.ecocomfort.set_mode_speed.assert_awaited_once_with( - "11223344", "1", "1" + "11223344", FanMode.inward, FanSpeed.sleep ) @@ -165,18 +166,18 @@ async def test_fan_set_percentage_zero_turns_off( ("service_data", "expected_mode", "expected_speed"), [ # percentage=None, preset_mode=None -> defaults to previous speed > 75% (medium), - # previous mode > "inward" - ({}, "1", "3"), - # percentage=0, preset_mode=None -> default 25% (sleep), previous mode (inward) - ({ATTR_PERCENTAGE: 0}, "1", "1"), + # previous mode > FanMode.inward + ({}, FanMode.inward, FanSpeed.medium), + # percentage=0, preset_mode=None -> default 25% (FanSpeed.sleep), previous mode (inward) + ({ATTR_PERCENTAGE: 0}, FanMode.inward, FanSpeed.sleep), ], ) async def test_fan_turn_on_defaulting_behavior( hass: HomeAssistant, mock_cloud_interface: AsyncMock, service_data: dict, - expected_mode: str, - expected_speed: str, + expected_mode: FanMode, + expected_speed: FanSpeed, ) -> None: """turn_on defaults percentage/preset as expected.""" data = {ATTR_ENTITY_ID: FAN_ENTITY_ID} | service_data diff --git a/tests/components/intelliclima/test_select.py b/tests/components/intelliclima/test_select.py index eb448d7edfc..b8d56bb1b08 100644 --- a/tests/components/intelliclima/test_select.py +++ b/tests/components/intelliclima/test_select.py @@ -86,10 +86,10 @@ async def test_select_option_keeps_current_speed( {ATTR_ENTITY_ID: SELECT_ENTITY_ID, ATTR_OPTION: option}, blocking=True, ) - # Device starts with speed_set="3" (from single_eco_device in conftest), + # Device starts with speed_set=FanSpeed.medium (from single_eco_device in conftest), # mode is not off and not auto, so current speed is preserved. mock_cloud_interface.ecocomfort.set_mode_speed.assert_awaited_once_with( - "11223344", expected_mode, "3" + "11223344", expected_mode, FanSpeed.medium ) @@ -119,9 +119,9 @@ async def test_select_option_in_auto_mode_defaults_speed_to_sleep( mock_cloud_interface: AsyncMock, single_eco_device, ) -> None: - """When speed_set is FanSpeed.auto (auto preset), selecting an option defaults to sleep speed.""" + """When speed_set is FanSpeed.auto_get (auto preset), selecting an option defaults to sleep speed.""" eco = list(single_eco_device.ecocomfort2_devices.values())[0] - eco.speed_set = FanSpeed.auto + eco.speed_set = FanSpeed.auto_get eco.mode_set = FanMode.sensor await hass.services.async_call(