From e99aaed7fab34ec30689f05e796cd87351e064ab Mon Sep 17 00:00:00 2001 From: G Johansson Date: Wed, 8 Jan 2025 09:30:14 +0100 Subject: [PATCH] Fix climate react type (#135030) --- homeassistant/components/sensibo/climate.py | 2 +- homeassistant/components/sensibo/sensor.py | 9 ++++++++- tests/components/sensibo/test_climate.py | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/sensibo/climate.py b/homeassistant/components/sensibo/climate.py index b35cb8af9a9..ff9aed6f4e7 100644 --- a/homeassistant/components/sensibo/climate.py +++ b/homeassistant/components/sensibo/climate.py @@ -199,7 +199,7 @@ async def async_setup_entry( vol.Required(ATTR_LOW_TEMPERATURE_THRESHOLD): vol.Coerce(float), vol.Required(ATTR_LOW_TEMPERATURE_STATE): dict, vol.Required(ATTR_SMART_TYPE): vol.In( - ["temperature", "feelsLike", "humidity"] + ["temperature", "feelslike", "humidity"] ), }, "async_enable_climate_react", diff --git a/homeassistant/components/sensibo/sensor.py b/homeassistant/components/sensibo/sensor.py index b395f8eb1ee..bea1326181c 100644 --- a/homeassistant/components/sensibo/sensor.py +++ b/homeassistant/components/sensibo/sensor.py @@ -36,6 +36,13 @@ from .entity import SensiboDeviceBaseEntity, SensiboMotionBaseEntity PARALLEL_UPDATES = 0 +def _smart_type_name(_type: str | None) -> str | None: + """Return a lowercase name of smart type.""" + if _type and _type == "feelsLike": + return "feelslike" + return _type + + @dataclass(frozen=True, kw_only=True) class SensiboMotionSensorEntityDescription(SensorEntityDescription): """Describes Sensibo Motion sensor entity.""" @@ -153,7 +160,7 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = ( SensiboDeviceSensorEntityDescription( key="climate_react_type", translation_key="smart_type", - value_fn=lambda data: data.smart_type, + value_fn=lambda data: _smart_type_name(data.smart_type), extra_fn=None, entity_registry_enabled_default=False, ), diff --git a/tests/components/sensibo/test_climate.py b/tests/components/sensibo/test_climate.py index d6176003582..7e848f3870c 100644 --- a/tests/components/sensibo/test_climate.py +++ b/tests/components/sensibo/test_climate.py @@ -954,7 +954,7 @@ async def test_climate_climate_react( "light": "on", }, "lowTemperatureThreshold": 5.5, - "type": "temperature", + "type": "feelsLike", }, } @@ -985,7 +985,7 @@ async def test_climate_climate_react( "horizontalSwing": "stopped", "light": "on", }, - ATTR_SMART_TYPE: "temperature", + ATTR_SMART_TYPE: "feelslike", }, blocking=True, ) @@ -993,7 +993,7 @@ async def test_climate_climate_react( mock_client.async_get_devices_data.return_value.parsed["ABC999111"].smart_on = True mock_client.async_get_devices_data.return_value.parsed[ "ABC999111" - ].smart_type = "temperature" + ].smart_type = "feelsLike" mock_client.async_get_devices_data.return_value.parsed[ "ABC999111" ].smart_low_temp_threshold = 5.5 @@ -1038,7 +1038,7 @@ async def test_climate_climate_react( hass.states.get("sensor.hallway_climate_react_high_temperature_threshold").state == "30.5" ) - assert hass.states.get("sensor.hallway_climate_react_type").state == "temperature" + assert hass.states.get("sensor.hallway_climate_react_type").state == "feelslike" @pytest.mark.usefixtures("entity_registry_enabled_by_default")