Fix climate react type (#135030)

This commit is contained in:
G Johansson 2025-01-08 09:30:14 +01:00 committed by GitHub
parent d000558227
commit e99aaed7fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 6 deletions

View File

@ -199,7 +199,7 @@ async def async_setup_entry(
vol.Required(ATTR_LOW_TEMPERATURE_THRESHOLD): vol.Coerce(float), vol.Required(ATTR_LOW_TEMPERATURE_THRESHOLD): vol.Coerce(float),
vol.Required(ATTR_LOW_TEMPERATURE_STATE): dict, vol.Required(ATTR_LOW_TEMPERATURE_STATE): dict,
vol.Required(ATTR_SMART_TYPE): vol.In( vol.Required(ATTR_SMART_TYPE): vol.In(
["temperature", "feelsLike", "humidity"] ["temperature", "feelslike", "humidity"]
), ),
}, },
"async_enable_climate_react", "async_enable_climate_react",

View File

@ -36,6 +36,13 @@ from .entity import SensiboDeviceBaseEntity, SensiboMotionBaseEntity
PARALLEL_UPDATES = 0 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) @dataclass(frozen=True, kw_only=True)
class SensiboMotionSensorEntityDescription(SensorEntityDescription): class SensiboMotionSensorEntityDescription(SensorEntityDescription):
"""Describes Sensibo Motion sensor entity.""" """Describes Sensibo Motion sensor entity."""
@ -153,7 +160,7 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
SensiboDeviceSensorEntityDescription( SensiboDeviceSensorEntityDescription(
key="climate_react_type", key="climate_react_type",
translation_key="smart_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, extra_fn=None,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),

View File

@ -954,7 +954,7 @@ async def test_climate_climate_react(
"light": "on", "light": "on",
}, },
"lowTemperatureThreshold": 5.5, "lowTemperatureThreshold": 5.5,
"type": "temperature", "type": "feelsLike",
}, },
} }
@ -985,7 +985,7 @@ async def test_climate_climate_react(
"horizontalSwing": "stopped", "horizontalSwing": "stopped",
"light": "on", "light": "on",
}, },
ATTR_SMART_TYPE: "temperature", ATTR_SMART_TYPE: "feelslike",
}, },
blocking=True, 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_on = True
mock_client.async_get_devices_data.return_value.parsed[ mock_client.async_get_devices_data.return_value.parsed[
"ABC999111" "ABC999111"
].smart_type = "temperature" ].smart_type = "feelsLike"
mock_client.async_get_devices_data.return_value.parsed[ mock_client.async_get_devices_data.return_value.parsed[
"ABC999111" "ABC999111"
].smart_low_temp_threshold = 5.5 ].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 hass.states.get("sensor.hallway_climate_react_high_temperature_threshold").state
== "30.5" == "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") @pytest.mark.usefixtures("entity_registry_enabled_by_default")