Fix Plugwise auto HVAC mode (#66639)

* Fix Plugwise auto hvac mode

* Clean up set HVAC
pull/66655/head
Franck Nijhof 2022-02-16 13:22:21 +01:00 committed by GitHub
parent 19d8b8a6ff
commit 4051e2f518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 11 deletions

View File

@ -140,20 +140,13 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
@plugwise_command
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
"""Set the hvac mode."""
if hvac_mode == HVAC_MODE_AUTO:
if (
schedule_temperature := self.device.get("schedule_temperature")
) is None:
raise ValueError("Cannot set HVAC mode to Auto: No schedule available")
await self.coordinator.api.set_temperature(
self.device["location"], schedule_temperature
)
if hvac_mode == HVAC_MODE_AUTO and not self.device.get("schedule_temperature"):
raise ValueError("Cannot set HVAC mode to Auto: No schedule available")
await self.coordinator.api.set_schedule_state(
self.device["location"],
self.device.get("last_used"),
"true" if hvac_mode == HVAC_MODE_AUTO else "false",
"on" if hvac_mode == HVAC_MODE_AUTO else "off",
)
@plugwise_command

View File

@ -206,7 +206,7 @@ async def test_anna_climate_entity_climate_changes(
assert mock_smile_anna.set_temperature.call_count == 1
assert mock_smile_anna.set_schedule_state.call_count == 1
mock_smile_anna.set_schedule_state.assert_called_with(
"c784ee9fdab44e1395b8dee7d7a497d5", None, "false"
"c784ee9fdab44e1395b8dee7d7a497d5", None, "off"
)
# Auto mode is not available, no schedules