Skip to content

Commit

Permalink
Add TURN_ON/OFF ClimateEntityFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
JoDehli committed Jan 31, 2024
1 parent 4e5c2ad commit f8faed6
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions custom_components/loxone/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
from abc import ABC

from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
from homeassistant.components.climate.const import ClimateEntityFeature, HVACMode, HVACAction
from homeassistant.components.climate.const import (
ClimateEntityFeature,
HVACMode,
HVACAction,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfTemperature
from homeassistant.core import HomeAssistant, callback
Expand Down Expand Up @@ -104,6 +108,13 @@ async def async_setup_entry(
class LoxoneRoomControllerV2(LoxoneEntity, ClimateEntity, ABC):
"""Loxone room controller"""

_attr_supported_features = (
ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.TURN_OFF
| ClimateEntityFeature.TURN_ON
)

def __init__(self, **kwargs):
_LOGGER.debug(f"Input: {kwargs}")
LoxoneEntity.__init__(self, **kwargs)
Expand All @@ -128,13 +139,6 @@ def get_mode_from_id(self, mode_id):
if mode["id"] == mode_id:
return mode["name"]

@property
def supported_features(self):
"""Flag supported features."""
return (
ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE
)

@property
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
Expand Down Expand Up @@ -218,7 +222,7 @@ def hvac_action(self) -> HVACAction | None:
"""Return the current HVAC action (heating, cooling)."""
if self.get_state_value("prepareState") == 1:
return HVACAction.PREHEATING
return None #return none due to unknown other state (HVACAction.IDLE, HVACAction.COOLING, HVACAction.HEATING)
return None # return none due to unknown other state (HVACAction.IDLE, HVACAction.COOLING, HVACAction.HEATING)

@property
def hvac_mode(self) -> HVACMode | None:
Expand Down Expand Up @@ -306,6 +310,9 @@ def set_preset_mode(self, preset_mode: str):
# ------------------ AC CONTROL --------------------------------------------------------
class LoxoneAcControl(LoxoneEntity, ClimateEntity, ABC):
"""Representation of a ACControl Loxone device."""
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE
)

def __init__(self, **kwargs):
_LOGGER.debug(f"Input AcControl: {kwargs}")
Expand All @@ -323,11 +330,6 @@ def __init__(self, **kwargs):
model="accontrol",
)

@property
def supported_features(self):
"""Flag supported features."""
return ClimateEntityFeature.TARGET_TEMPERATURE

@property
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
Expand Down

0 comments on commit f8faed6

Please sign in to comment.