Clean up set_hvac_mode in Touchline (#194054)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Magnus Nordseth
2026-11-24 08:59:54 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 89ae104da7
commit 281cb87f60
2 changed files with 29 additions and 4 deletions
@@ -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:
+25 -1
View File
@@ -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()