From 4051e2f518964dbdbbf326c984a656e0ca188fbf Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 16 Feb 2022 13:22:21 +0100 Subject: [PATCH] Fix Plugwise auto HVAC mode (#66639) * Fix Plugwise auto hvac mode * Clean up set HVAC --- homeassistant/components/plugwise/climate.py | 13 +++---------- tests/components/plugwise/test_climate.py | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/plugwise/climate.py b/homeassistant/components/plugwise/climate.py index a3354007868..abf08b70dad 100644 --- a/homeassistant/components/plugwise/climate.py +++ b/homeassistant/components/plugwise/climate.py @@ -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 diff --git a/tests/components/plugwise/test_climate.py b/tests/components/plugwise/test_climate.py index 6f9a258bb38..c40ad32c078 100644 --- a/tests/components/plugwise/test_climate.py +++ b/tests/components/plugwise/test_climate.py @@ -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