mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 17:18:23 +00:00
Fix climate reproduce_state to handle thermostats with all temperature values None
Co-authored-by: mib1185 <35783820+mib1185@users.noreply.github.com>
This commit is contained in:
parent
54ecb94db1
commit
192a2c1beb
@ -57,9 +57,9 @@ async def _async_reproduce_states(
|
||||
await call_service(SERVICE_SET_HVAC_MODE, [], {ATTR_HVAC_MODE: state.state})
|
||||
|
||||
if (
|
||||
(ATTR_TEMPERATURE in state.attributes)
|
||||
or (ATTR_TARGET_TEMP_HIGH in state.attributes)
|
||||
or (ATTR_TARGET_TEMP_LOW in state.attributes)
|
||||
(ATTR_TEMPERATURE in state.attributes and state.attributes[ATTR_TEMPERATURE] is not None)
|
||||
or (ATTR_TARGET_TEMP_HIGH in state.attributes and state.attributes[ATTR_TARGET_TEMP_HIGH] is not None)
|
||||
or (ATTR_TARGET_TEMP_LOW in state.attributes and state.attributes[ATTR_TARGET_TEMP_LOW] is not None)
|
||||
):
|
||||
await call_service(
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
|
@ -192,3 +192,33 @@ async def test_attribute_partial_high_low_temperature(hass: HomeAssistant) -> No
|
||||
ATTR_TARGET_TEMP_HIGH: 30.1,
|
||||
ATTR_TARGET_TEMP_LOW: 20.2,
|
||||
}
|
||||
|
||||
|
||||
async def test_all_temperature_attributes_none(hass: HomeAssistant) -> None:
|
||||
"""Test that set_temperature service is not called when all temperature attributes are None."""
|
||||
calls_temp = async_mock_service(hass, DOMAIN, SERVICE_SET_TEMPERATURE)
|
||||
calls_hvac = async_mock_service(hass, DOMAIN, SERVICE_SET_HVAC_MODE)
|
||||
|
||||
await async_reproduce_states(
|
||||
hass,
|
||||
[
|
||||
State(
|
||||
ENTITY_1,
|
||||
HVACMode.OFF,
|
||||
{
|
||||
ATTR_TEMPERATURE: None,
|
||||
ATTR_TARGET_TEMP_HIGH: None,
|
||||
ATTR_TARGET_TEMP_LOW: None,
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Should call set_hvac_mode with OFF but not call set_temperature
|
||||
assert len(calls_hvac) == 1
|
||||
assert calls_hvac[0].data == {"entity_id": ENTITY_1, "hvac_mode": HVACMode.OFF}
|
||||
|
||||
# Should NOT call set_temperature when all temperature attributes are None
|
||||
assert len(calls_temp) == 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user