mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Set climate state to off if is_on
is False
This commit is contained in:
parent
a117a3cba9
commit
4ad5ce6d52
@ -354,6 +354,8 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
hvac_mode = self.hvac_mode
|
||||
if hvac_mode is None:
|
||||
return None
|
||||
if hasattr(self, "_attr_is_on") and self._attr_is_on is False:
|
||||
return HVACMode.OFF.value
|
||||
# Support hvac_mode as string for custom integration backwards compatibility
|
||||
if not isinstance(hvac_mode, HVACMode):
|
||||
return HVACMode(hvac_mode).value # type: ignore[unreachable]
|
||||
|
@ -490,6 +490,13 @@ async def test_turn_on_off_toggle(hass: HomeAssistant) -> None:
|
||||
climate._attr_hvac_mode = None
|
||||
assert climate.is_on is None
|
||||
|
||||
# If _attr_is_on is set to False the state should be always off
|
||||
climate._attr_hvac_action = HVACAction.IDLE
|
||||
climate._attr_hvac_mode = HVACMode.AUTO
|
||||
climate._attr_is_on = False
|
||||
assert climate.is_on is False
|
||||
assert climate.state == HVACMode.OFF
|
||||
|
||||
|
||||
async def test_sync_toggle(hass: HomeAssistant) -> None:
|
||||
"""Test if async toggle calls sync toggle."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user