From 27a267139f627fd460acfcb915126cdb7f378e42 Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Wed, 20 Dec 2023 19:06:34 +0000 Subject: [PATCH] FIX #159 - Doesn't send target temp if VTherm is off --- .../versatile_thermostat/thermostat_climate.py | 5 +++++ tests/test_bugs.py | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/custom_components/versatile_thermostat/thermostat_climate.py b/custom_components/versatile_thermostat/thermostat_climate.py index 784e107..446fb01 100644 --- a/custom_components/versatile_thermostat/thermostat_climate.py +++ b/custom_components/versatile_thermostat/thermostat_climate.py @@ -136,6 +136,11 @@ class ThermostatOverClimate(BaseThermostat): async def _send_regulated_temperature(self, force=False): """Sends the regulated temperature to all underlying""" + + if self.hvac_mode == HVACMode.OFF: + _LOGGER.debug("%s - don't send regulated temperature cause VTherm is off ") + return + _LOGGER.info( "%s - Calling ThermostatClimate._send_regulated_temperature force=%s", self, diff --git a/tests/test_bugs.py b/tests/test_bugs.py index d7cdda9..7be51ad 100644 --- a/tests/test_bugs.py +++ b/tests/test_bugs.py @@ -629,13 +629,18 @@ async def test_bug_272( assert mock_service_call.call_count == 0 # Set the hvac_mode to HEAT - entity.async_set_hvac_mode(HVACMode.HEAT) + await entity.async_set_hvac_mode(HVACMode.HEAT) # In the accepted interval await entity.async_set_temperature(temperature=17) - assert mock_service_call.call_count == 1 + assert mock_service_call.call_count == 2 mock_service_call.assert_has_calls( [ + call.async_call( + "climate", + SERVICE_SET_HVAC_MODE, + {"entity_id": "climate.mock_climate", "hvac_mode": HVACMode.HEAT}, + ), call.async_call( "climate", SERVICE_SET_TEMPERATURE,