Fix Sensibo full_state action modifying the coordinator data (#187014)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
DeviousCardi
2026-10-23 17:50:02 +00:00
committed by Franck Nijhof
co-authored by Claude Opus 5.5
parent c4380e48df
commit ff3fed6913
2 changed files with 52 additions and 2 deletions
+5 -2
View File
@@ -419,8 +419,11 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
light: str | None = None,
) -> None:
"""Set full AC state."""
new_ac_state = self.device_data.ac_states
new_ac_state.pop("timestamp")
new_ac_state = {
key: value
for key, value in self.device_data.ac_states.items()
if key != "timestamp"
}
new_ac_state["on"] = False
if mode != "off":
new_ac_state["on"] = True
+47
View File
@@ -1263,6 +1263,53 @@ async def test_climate_full_ac_state(
assert state.attributes["temperature"] == 22
async def test_climate_full_ac_state_keeps_device_data(
hass: HomeAssistant,
load_int: ConfigEntry,
mock_client: MagicMock,
) -> None:
"""Test the Full AC state service does not modify the coordinator data."""
ac_states = load_int.runtime_data.data.parsed["ABC999111"].ac_states
original_ac_states = ac_states.copy()
service_data = {
ATTR_ENTITY_ID: "climate.hallway_hallway",
ATTR_MODE: "cool",
ATTR_TARGET_TEMPERATURE: 22,
}
expected_payload = {
"on": True,
"mode": "cool",
"fanLevel": "high",
"targetTemperature": 22,
"swing": "stopped",
"horizontalSwing": "stopped",
"light": "on",
}
# A failed call does not refresh the coordinator, so the next call
# works on the same device data.
mock_client.async_set_ac_states.return_value = {"result": {"status": "Failed"}}
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
DOMAIN, SERVICE_FULL_STATE, service_data, blocking=True
)
assert ac_states == original_ac_states
mock_client.async_set_ac_states.assert_called_once_with(
"ABC999111", expected_payload
)
mock_client.async_set_ac_states.reset_mock()
mock_client.async_set_ac_states.return_value = {"result": {"status": "Success"}}
await hass.services.async_call(
DOMAIN, SERVICE_FULL_STATE, service_data, blocking=True
)
mock_client.async_set_ac_states.assert_called_once_with(
"ABC999111", expected_payload
)
async def test_climate_fan_mode_and_swing_mode_not_supported(
hass: HomeAssistant,
load_int: ConfigEntry,