diff --git a/homeassistant/components/knx/climate.py b/homeassistant/components/knx/climate.py index 674e76d66e3..e1179641cdc 100644 --- a/homeassistant/components/knx/climate.py +++ b/homeassistant/components/knx/climate.py @@ -283,16 +283,13 @@ class KNXClimate(KnxEntity, ClimateEntity): ) 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: diff --git a/tests/components/knx/test_climate.py b/tests/components/knx/test_climate.py index 3b286a0cdb9..9c431386b43 100644 --- a/tests/components/knx/test_climate.py +++ b/tests/components/knx/test_climate.py @@ -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( @@ -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"]) @@ -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( @@ -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(