From 281cb87f60852666f73b1c2d2a4b1365e90f404b Mon Sep 17 00:00:00 2001 From: Magnus Nordseth Date: Tue, 24 Nov 2026 08:59:54 +0100 Subject: [PATCH] Clean up set_hvac_mode in Touchline (#194054) Co-authored-by: Claude Opus 5.5 --- homeassistant/components/touchline/climate.py | 7 ++--- tests/components/touchline/test_climate.py | 26 ++++++++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/touchline/climate.py b/homeassistant/components/touchline/climate.py index a781cdd331c9..8439b541b801 100644 --- a/homeassistant/components/touchline/climate.py +++ b/homeassistant/components/touchline/climate.py @@ -83,7 +83,6 @@ class Touchline(ClimateEntity): ) self._attr_native_current_temperature = self.unit.get_current_temperature() self._attr_native_target_temperature = self.unit.get_target_temperature() - self._current_operation_mode = HVACMode.HEAT self._attr_preset_mode = TOUCHLINE_HA_PRESETS.get( (self.unit.get_operation_mode(), self.unit.get_week_program()) ) @@ -116,8 +115,10 @@ class Touchline(ClimateEntity): @override def set_hvac_mode(self, hvac_mode: HVACMode) -> None: - """Set new target hvac mode.""" - self._current_operation_mode = HVACMode.HEAT + """Set new target hvac mode. + + Heat is the only supported mode, so there is nothing to change. + """ @override def set_temperature(self, **kwargs: Any) -> None: diff --git a/tests/components/touchline/test_climate.py b/tests/components/touchline/test_climate.py index 0a3c4d312471..0a08ac971d13 100644 --- a/tests/components/touchline/test_climate.py +++ b/tests/components/touchline/test_climate.py @@ -7,7 +7,11 @@ from pytest_homeassistant.common import MockConfigEntry, snapshot_platform from pytouchline_extended import TouchlineConnectionError from syrupy.assertion import SnapshotAssertion -from homeassistant.components.climate import ClimateService, ClimateServiceArgument +from homeassistant.components.climate import ( + ClimateService, + ClimateServiceArgument, + HVACMode, +) from homeassistant.const import TargetKey from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError @@ -140,3 +144,23 @@ async def test_set_preset_mode_error( }, blocking=True, ) + + +@pytest.mark.usefixtures("init_integration") +async def test_set_hvac_mode_heat( + hass: HomeAssistant, + mock_pytouchline: MagicMock, +) -> None: + """Test setting the only supported HVAC mode does not write to the controller.""" + await hass.services.async_call( + "climate", + ClimateService.SET_HVAC_MODE, + { + TargetKey.ENTITY_ID: "climate.zone_1", + ClimateServiceArgument.HVAC_MODE: HVACMode.HEAT, + }, + blocking=True, + ) + + assert hass.states.get("climate.zone_1").state == HVACMode.HEAT + mock_pytouchline.set_operation_mode.assert_not_called()