Skip to content

Commit

Permalink
Set temp for manual mode only.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoDehli committed Nov 8, 2024
1 parent 9661672 commit e65166e
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions custom_components/loxone/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ 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
)
# attr_supported_features = (
# ClimateEntityFeature.PRESET_MODE
# | ClimateEntityFeature.TARGET_TEMPERATURE
# | ClimateEntityFeature.TURN_OFF
# | ClimateEntityFeature.TURN_ON
# )

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand All @@ -118,6 +118,16 @@ def __init__(self, **kwargs):
self.unique_id, self.name, self.type, self.room
)

@property
def supported_features(self):
features = ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON

# Dynamically add TARGET_TEMPERATURE if operatingMode is larger than 2
if self.get_state_value("operatingMode") and self.get_state_value("operatingMode") > 2:
features |= ClimateEntityFeature.TARGET_TEMPERATURE

return features

def get_mode_from_id(self, mode_id):
for mode in self._modeList:
if mode["id"] == mode_id:
Expand Down Expand Up @@ -182,14 +192,14 @@ def set_temperature(self, **kwargs):
value=f'setManualTemperature/{kwargs["temperature"]}',
),
)
else: # Set comfort temp offset otherwise
new_offset = kwargs["temperature"] - self.get_state_value(
"comfortTemperature"
)
self.hass.bus.fire(
SENDDOMAIN,
dict(uuid=self.uuidAction, value=f"setComfortModeTemp/{new_offset}"),
)
# else: # Set comfort temp offset otherwise
# new_offset = kwargs["temperature"] - self.get_state_value(
# "comfortTemperature"
# )
# self.hass.bus.fire(
# SENDDOMAIN,
# dict(uuid=self.uuidAction, value=f"setComfortModeTemp/{new_offset}"),
# )

@property
def hvac_action(self) -> HVACAction | None:
Expand Down

0 comments on commit e65166e

Please sign in to comment.