mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Respect ESPHome ClimateTrait supports_current_temperature (#132149)
This commit is contained in:
parent
939365887f
commit
cf3d4eb26a
@ -230,6 +230,8 @@ class EsphomeClimateEntity(EsphomeEntity[ClimateInfo, ClimateState], ClimateEnti
|
|||||||
@esphome_float_state_property
|
@esphome_float_state_property
|
||||||
def current_temperature(self) -> float | None:
|
def current_temperature(self) -> float | None:
|
||||||
"""Return the current temperature."""
|
"""Return the current temperature."""
|
||||||
|
if not self._static_info.supports_current_temperature:
|
||||||
|
return None
|
||||||
return self._state.current_temperature
|
return self._state.current_temperature
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -484,3 +484,36 @@ async def test_climate_entity_attributes(
|
|||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.state == HVACMode.COOL
|
assert state.state == HVACMode.COOL
|
||||||
assert state.attributes == snapshot(name="climate-entity-attributes")
|
assert state.attributes == snapshot(name="climate-entity-attributes")
|
||||||
|
|
||||||
|
|
||||||
|
async def test_climate_entity_attribute_current_temperature_unsupported(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_client: APIClient,
|
||||||
|
mock_generic_device_entry,
|
||||||
|
) -> None:
|
||||||
|
"""Test a climate entity with current temperature unsupported."""
|
||||||
|
entity_info = [
|
||||||
|
ClimateInfo(
|
||||||
|
object_id="myclimate",
|
||||||
|
key=1,
|
||||||
|
name="my climate",
|
||||||
|
unique_id="my_climate",
|
||||||
|
supports_current_temperature=False,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
states = [
|
||||||
|
ClimateState(
|
||||||
|
key=1,
|
||||||
|
current_temperature=30,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
user_service = []
|
||||||
|
await mock_generic_device_entry(
|
||||||
|
mock_client=mock_client,
|
||||||
|
entity_info=entity_info,
|
||||||
|
user_service=user_service,
|
||||||
|
states=states,
|
||||||
|
)
|
||||||
|
state = hass.states.get("climate.test_myclimate")
|
||||||
|
assert state is not None
|
||||||
|
assert state.attributes[ATTR_CURRENT_TEMPERATURE] is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user