mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Add current hvac_action to KNX climate (#51464)
This commit is contained in:
parent
16d5d7e508
commit
b08f473da4
@ -10,6 +10,8 @@ from xknx.telegram.address import parse_device_group_address
|
|||||||
|
|
||||||
from homeassistant.components.climate import ClimateEntity
|
from homeassistant.components.climate import ClimateEntity
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
|
CURRENT_HVAC_IDLE,
|
||||||
|
CURRENT_HVAC_OFF,
|
||||||
HVAC_MODE_HEAT,
|
HVAC_MODE_HEAT,
|
||||||
HVAC_MODE_OFF,
|
HVAC_MODE_OFF,
|
||||||
PRESET_AWAY,
|
PRESET_AWAY,
|
||||||
@ -22,7 +24,7 @@ from homeassistant.helpers import entity_registry as er
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from .const import CONTROLLER_MODES, DOMAIN, PRESET_MODES
|
from .const import CONTROLLER_MODES, CURRENT_HVAC_ACTIONS, DOMAIN, PRESET_MODES
|
||||||
from .knx_entity import KnxEntity
|
from .knx_entity import KnxEntity
|
||||||
from .schema import ClimateSchema
|
from .schema import ClimateSchema
|
||||||
|
|
||||||
@ -260,6 +262,20 @@ class KNXClimate(KnxEntity, ClimateEntity):
|
|||||||
# default to ["heat"]
|
# default to ["heat"]
|
||||||
return hvac_modes if hvac_modes else [HVAC_MODE_HEAT]
|
return hvac_modes if hvac_modes else [HVAC_MODE_HEAT]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_action(self) -> str | None:
|
||||||
|
"""Return the current running hvac operation if supported.
|
||||||
|
|
||||||
|
Need to be one of CURRENT_HVAC_*.
|
||||||
|
"""
|
||||||
|
if self._device.supports_on_off and not self._device.is_on:
|
||||||
|
return CURRENT_HVAC_OFF
|
||||||
|
if self._device.mode is not None and self._device.mode.supports_controller_mode:
|
||||||
|
return CURRENT_HVAC_ACTIONS.get(
|
||||||
|
self._device.mode.controller_mode.value, CURRENT_HVAC_IDLE
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
||||||
"""Set operation mode."""
|
"""Set operation mode."""
|
||||||
if self._device.supports_on_off and hvac_mode == HVAC_MODE_OFF:
|
if self._device.supports_on_off and hvac_mode == HVAC_MODE_OFF:
|
||||||
|
@ -3,6 +3,11 @@ from enum import Enum
|
|||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
|
CURRENT_HVAC_COOL,
|
||||||
|
CURRENT_HVAC_DRY,
|
||||||
|
CURRENT_HVAC_FAN,
|
||||||
|
CURRENT_HVAC_HEAT,
|
||||||
|
CURRENT_HVAC_OFF,
|
||||||
HVAC_MODE_AUTO,
|
HVAC_MODE_AUTO,
|
||||||
HVAC_MODE_COOL,
|
HVAC_MODE_COOL,
|
||||||
HVAC_MODE_DRY,
|
HVAC_MODE_DRY,
|
||||||
@ -68,6 +73,14 @@ CONTROLLER_MODES: Final = {
|
|||||||
"Dry": HVAC_MODE_DRY,
|
"Dry": HVAC_MODE_DRY,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CURRENT_HVAC_ACTIONS: Final = {
|
||||||
|
"Heat": CURRENT_HVAC_HEAT,
|
||||||
|
"Cool": CURRENT_HVAC_COOL,
|
||||||
|
"Off": CURRENT_HVAC_OFF,
|
||||||
|
"Fan only": CURRENT_HVAC_FAN,
|
||||||
|
"Dry": CURRENT_HVAC_DRY,
|
||||||
|
}
|
||||||
|
|
||||||
PRESET_MODES: Final = {
|
PRESET_MODES: Final = {
|
||||||
# Map DPT 20.102 HVAC operating modes to HA presets
|
# Map DPT 20.102 HVAC operating modes to HA presets
|
||||||
"Auto": PRESET_NONE,
|
"Auto": PRESET_NONE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user