Skip to content

Commit

Permalink
Fix climate react type
Browse files Browse the repository at this point in the history
  • Loading branch information
gjohansson-ST committed Jan 7, 2025
1 parent 1496da8 commit a7374f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/sensibo/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion homeassistant/components/sensibo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
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."""
Expand Down Expand Up @@ -153,7 +160,7 @@ class SensiboDeviceSensorEntityDescription(SensorEntityDescription):
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,
),
Expand Down
8 changes: 4 additions & 4 deletions tests/components/sensibo/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ async def test_climate_climate_react(
"light": "on",
},
"lowTemperatureThreshold": 5.5,
"type": "temperature",
"type": "feelsLike",
},
}

Expand Down Expand Up @@ -985,15 +985,15 @@ async def test_climate_climate_react(
"horizontalSwing": "stopped",
"light": "on",
},
ATTR_SMART_TYPE: "temperature",
ATTR_SMART_TYPE: "feelslike",
},
blocking=True,
)

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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit a7374f1

Please sign in to comment.