Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions homeassistant/components/knx/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,13 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
)
if knx_controller_mode in self._device.mode.controller_modes:
await self._device.mode.set_controller_mode(knx_controller_mode)
self.async_write_ha_state()
return

if self._device.supports_on_off:
if hvac_mode == HVACMode.OFF:
await self._device.turn_off()
elif not self._device.is_on:
# for default hvac mode, otherwise above would have triggered
await self._device.turn_on()
self.async_write_ha_state()
self.async_write_ha_state()

@property
def preset_mode(self) -> str | None:
Expand Down
10 changes: 9 additions & 1 deletion tests/components/knx/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ async def test_climate_on_off(
blocking=True,
)
await knx.assert_write(on_off_ga, 0)
assert hass.states.get("climate.test").state == "off"

# set hvac mode to heat
await hass.services.async_call(
Expand All @@ -137,10 +138,11 @@ async def test_climate_on_off(
blocking=True,
)
if heat_cool_ga:
# only set new hvac_mode without changing on/off - actuator shall handle that
await knx.assert_write(heat_cool_ga, 1)
await knx.assert_write(on_off_ga, 1)
else:
await knx.assert_write(on_off_ga, 1)
assert hass.states.get("climate.test").state == "heat"


@pytest.mark.parametrize("on_off_ga", [None, "4/4/4"])
Expand Down Expand Up @@ -190,6 +192,9 @@ async def test_climate_hvac_mode(
blocking=True,
)
await knx.assert_write(controller_mode_ga, (0x06,))
if on_off_ga:
await knx.assert_write(on_off_ga, 0)
assert hass.states.get("climate.test").state == "off"

# set hvac to non default mode
await hass.services.async_call(
Expand All @@ -199,6 +204,9 @@ async def test_climate_hvac_mode(
blocking=True,
)
await knx.assert_write(controller_mode_ga, (0x03,))
if on_off_ga:
await knx.assert_write(on_off_ga, 1)
assert hass.states.get("climate.test").state == "cool"

# turn off
await hass.services.async_call(
Expand Down