mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Fix scene activation with climate entities with None
attribute values (#110684)
don't call service with attribute None
This commit is contained in:
parent
5292c3408e
commit
58a6f26f66
@ -68,13 +68,22 @@ async def _async_reproduce_states(
|
||||
[ATTR_TEMPERATURE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW],
|
||||
)
|
||||
|
||||
if ATTR_PRESET_MODE in state.attributes:
|
||||
if (
|
||||
ATTR_PRESET_MODE in state.attributes
|
||||
and state.attributes[ATTR_PRESET_MODE] is not None
|
||||
):
|
||||
await call_service(SERVICE_SET_PRESET_MODE, [ATTR_PRESET_MODE])
|
||||
|
||||
if ATTR_SWING_MODE in state.attributes:
|
||||
if (
|
||||
ATTR_SWING_MODE in state.attributes
|
||||
and state.attributes[ATTR_SWING_MODE] is not None
|
||||
):
|
||||
await call_service(SERVICE_SET_SWING_MODE, [ATTR_SWING_MODE])
|
||||
|
||||
if ATTR_FAN_MODE in state.attributes:
|
||||
if (
|
||||
ATTR_FAN_MODE in state.attributes
|
||||
and state.attributes[ATTR_FAN_MODE] is not None
|
||||
):
|
||||
await call_service(SERVICE_SET_FAN_MODE, [ATTR_FAN_MODE])
|
||||
|
||||
if ATTR_HUMIDITY in state.attributes:
|
||||
|
@ -119,6 +119,25 @@ async def test_attribute(hass: HomeAssistant, service, attribute) -> None:
|
||||
assert calls_1[0].data == {"entity_id": ENTITY_1, attribute: value}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("service", "attribute"),
|
||||
[
|
||||
(SERVICE_SET_PRESET_MODE, ATTR_PRESET_MODE),
|
||||
(SERVICE_SET_SWING_MODE, ATTR_SWING_MODE),
|
||||
(SERVICE_SET_FAN_MODE, ATTR_FAN_MODE),
|
||||
],
|
||||
)
|
||||
async def test_attribute_with_none(hass: HomeAssistant, service, attribute) -> None:
|
||||
"""Test that service call is not made for attributes with None value."""
|
||||
calls_1 = async_mock_service(hass, DOMAIN, service)
|
||||
|
||||
await async_reproduce_states(hass, [State(ENTITY_1, None, {attribute: None})])
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(calls_1) == 0
|
||||
|
||||
|
||||
async def test_attribute_partial_temperature(hass: HomeAssistant) -> None:
|
||||
"""Test that service call ignores null attributes."""
|
||||
calls_1 = async_mock_service(hass, DOMAIN, SERVICE_SET_TEMPERATURE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user