Skip to content

Commit

Permalink
Add OPTIMUM_START_STOP and TEMPERATURE_OFFSET to climate (#1770)
Browse files Browse the repository at this point in the history
* OPTIMUM_START_STOP and TEMPERATURE_OFFSET to climate master parameters

* Add OPTIMUM_START_STOP and TEMPERATURE_OFFSET to climate
  • Loading branch information
SukramJ authored Oct 13, 2024
1 parent 5588b9c commit 7a2dd39
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 101 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Version 2024.10.7 (2024-10-12)

- Add OPTIMUM_START_STOP and TEMPERATURE_OFFSET to climate
- Improve profile validation
- Use regex to identify schedule profiles

Expand Down
63 changes: 19 additions & 44 deletions hahomematic/caches/visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,22 @@
# from being display by default. Usually these enties are used within custom entities,
# and not for general display.
# {model: (channel_no, parameter)}

_CLIMATE_MASTER_PARAMETERS: Final[tuple[Parameter, ...]] = (
Parameter.GLOBAL_BUTTON_LOCK,
Parameter.OPTIMUM_START_STOP,
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.TEMPERATURE_OFFSET,
)
_RELEVANT_MASTER_PARAMSETS_BY_DEVICE: Final[
Mapping[str, tuple[tuple[int | None, ...], tuple[Parameter, ...]]]
] = {
"ALPHA-IP-RBG": (
(0, 1),
(
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.GLOBAL_BUTTON_LOCK,
),
),
"HM-CC-RT-DN": (
(None, 1),
(
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.GLOBAL_BUTTON_LOCK,
),
),
"HM-CC-VG-1": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"ALPHA-IP-RBG": ((0, 1), _CLIMATE_MASTER_PARAMETERS),
"HM-CC-RT-DN": ((None, 1), _CLIMATE_MASTER_PARAMETERS),
"HM-CC-VG-1": ((0, 1), _CLIMATE_MASTER_PARAMETERS),
"HM-TC-IT-WM-W-EU": ((None,), (Parameter.GLOBAL_BUTTON_LOCK,)),
"HmIP-BWTH": (
(0, 1),
(
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.GLOBAL_BUTTON_LOCK,
),
),
"HmIP-BWTH": ((0, 1), _CLIMATE_MASTER_PARAMETERS),
"HmIP-DRBLI4": (
(1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 17, 21),
(Parameter.CHANNEL_OPERATION_MODE,),
Expand All @@ -70,33 +57,19 @@
"HmIP-FCI1": ((1,), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-FCI6": (tuple(range(1, 7)), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-FSI16": ((1,), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-HEATING": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-HEATING": ((0, 1), _CLIMATE_MASTER_PARAMETERS),
"HmIP-MIO16-PCB": ((13, 14, 15, 16), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-MOD-RC8": (tuple(range(1, 9)), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-RGBW": ((0,), (Parameter.DEVICE_OPERATION_MODE,)),
"HmIP-STH": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-WTH": (
(0, 1),
(
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.GLOBAL_BUTTON_LOCK,
),
),
"HmIP-eTRV": (
(0, 1),
(
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.GLOBAL_BUTTON_LOCK,
),
),
"HmIP-STH": ((1,), _CLIMATE_MASTER_PARAMETERS),
"HmIP-WTH": ((0, 1), _CLIMATE_MASTER_PARAMETERS),
"HmIP-eTRV": ((0, 1), _CLIMATE_MASTER_PARAMETERS),
"HmIPW-DRBL4": ((1, 5, 9, 13), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIPW-DRI16": (tuple(range(1, 17)), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIPW-DRI32": (tuple(range(1, 33)), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIPW-FAL": ((0,), (Parameter.GLOBAL_BUTTON_LOCK,)),
"HmIPW-FIO6": (tuple(range(1, 7)), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIPW-STH": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIPW-STH": ((0, 1), _CLIMATE_MASTER_PARAMETERS),
}

# Ignore events for some devices
Expand All @@ -111,10 +84,12 @@
Parameter.CONFIG_PENDING,
Parameter.DIRECTION,
Parameter.ERROR,
Parameter.OPTIMUM_START_STOP,
Parameter.SECTION,
Parameter.STICKY_UN_REACH,
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.TEMPERATURE_OFFSET,
Parameter.UN_REACH,
Parameter.UPDATE_PENDING,
Parameter.WORKING,
Expand Down
96 changes: 60 additions & 36 deletions hahomematic/platforms/custom/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,30 @@ def _init_entity_fields(self) -> None:
field=Field.TEMPERATURE_MINIMUM, entity_type=HmFloat
)

@config_property
def temperature_unit(self) -> str:
"""Return temperature unit."""
return _TEMP_CELSIUS
@state_property
def current_humidity(self) -> int | None:
"""Return the current humidity."""
return self._e_humidity.value

@state_property
def current_temperature(self) -> float | None:
"""Return current temperature."""
return self._e_temperature.value

@state_property
def hvac_action(self) -> HmHvacAction | None:
"""Return the hvac action."""
return None

@state_property
def hvac_mode(self) -> HmHvacMode:
"""Return hvac operation mode."""
return HmHvacMode.HEAT

@state_property
def hvac_modes(self) -> tuple[HmHvacMode, ...]:
"""Return the available hvac operation modes."""
return (HmHvacMode.HEAT,)

@state_property
def min_temp(self) -> float:
Expand All @@ -202,14 +222,14 @@ def max_temp(self) -> float:
return self._e_setpoint.max # type: ignore[no-any-return]

@state_property
def current_humidity(self) -> int | None:
"""Return the current humidity."""
return self._e_humidity.value
def preset_mode(self) -> HmPresetMode:
"""Return the current preset mode."""
return HmPresetMode.NONE

@state_property
def current_temperature(self) -> float | None:
"""Return current temperature."""
return self._e_temperature.value
def preset_modes(self) -> tuple[HmPresetMode, ...]:
"""Return available preset modes."""
return (HmPresetMode.NONE,)

@state_property
def target_temperature(self) -> float | None:
Expand All @@ -221,36 +241,16 @@ def target_temperature_step(self) -> float:
"""Return the supported step of target temperature."""
return _DEFAULT_TEMPERATURE_STEP

@state_property
def preset_mode(self) -> HmPresetMode:
"""Return the current preset mode."""
return HmPresetMode.NONE

@state_property
def preset_modes(self) -> tuple[HmPresetMode, ...]:
"""Return available preset modes."""
return (HmPresetMode.NONE,)

@state_property
def hvac_action(self) -> HmHvacAction | None:
"""Return the hvac action."""
return None

@state_property
def hvac_mode(self) -> HmHvacMode:
"""Return hvac operation mode."""
return HmHvacMode.HEAT

@state_property
def hvac_modes(self) -> tuple[HmHvacMode, ...]:
"""Return the available hvac operation modes."""
return (HmHvacMode.HEAT,)

@property
def supports_preset(self) -> bool:
"""Flag if climate supports preset."""
return False

@config_property
def temperature_unit(self) -> str:
"""Return temperature unit."""
return _TEMP_CELSIUS

@property
def _min_or_target_temperature(self) -> float:
"""Return the min or target temperature."""
Expand Down Expand Up @@ -590,6 +590,9 @@ def _init_entity_fields(self) -> None:
self._e_control_mode: HmSensor[str | None] = self._get_entity(
field=Field.CONTROL_MODE, entity_type=HmSensor[str | None]
)
self._e_temperature_offset: HmSelect = self._get_entity(
field=Field.TEMPERATURE_OFFSET, entity_type=HmSelect
)
self._e_valve_state: HmSensor[int | None] = self._get_entity(
field=Field.VALVE_STATE, entity_type=HmSensor[int | None]
)
Expand Down Expand Up @@ -645,6 +648,11 @@ def supports_preset(self) -> bool:
"""Flag if climate supports preset."""
return True

@state_property
def temperature_offset(self) -> str | None:
"""Return the maximum temperature."""
return self._e_temperature_offset.value

@bind_collector()
async def set_hvac_mode(
self, hvac_mode: HmHvacMode, collector: CallParameterCollector | None = None
Expand Down Expand Up @@ -745,16 +753,22 @@ def _init_entity_fields(self) -> None:
self._e_heating_mode: HmSelect = self._get_entity(
field=Field.HEATING_COOLING, entity_type=HmSelect
)
self._e_level: HmFloat = self._get_entity(field=Field.LEVEL, entity_type=HmFloat)
self._e_optimum_start_stop: HmBinarySensor = self._get_entity(
field=Field.OPTIMUM_START_STOP, entity_type=HmBinarySensor
)
self._e_party_mode: HmBinarySensor = self._get_entity(
field=Field.PARTY_MODE, entity_type=HmBinarySensor
)
self._e_set_point_mode: HmInteger = self._get_entity(
field=Field.SET_POINT_MODE, entity_type=HmInteger
)
self._e_level: HmFloat = self._get_entity(field=Field.LEVEL, entity_type=HmFloat)
self._e_state: HmBinarySensor = self._get_entity(
field=Field.STATE, entity_type=HmBinarySensor
)
self._e_temperature_offset: HmFloat = self._get_entity(
field=Field.TEMPERATURE_OFFSET, entity_type=HmFloat
)

@property
def _is_heating_mode(self) -> bool:
Expand Down Expand Up @@ -815,11 +829,21 @@ def preset_modes(self) -> tuple[HmPresetMode, ...]:
presets.extend(self._profile_names)
return tuple(presets)

@property
def optimum_start_stop(self) -> bool | None:
"""Return if optimum_start_stop is enabled."""
return self._e_optimum_start_stop.value

@property
def supports_preset(self) -> bool:
"""Flag if climate supports preset."""
return True

@state_property
def temperature_offset(self) -> float | None:
"""Return the maximum temperature."""
return self._e_temperature_offset.value

@bind_collector()
async def set_hvac_mode(
self, hvac_mode: HmHvacMode, collector: CallParameterCollector | None = None
Expand Down
2 changes: 2 additions & 0 deletions hahomematic/platforms/custom/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Field(Enum):
OPERATING_VOLTAGE = "operating_voltage"
OPTICAL_ALARM_ACTIVE = "optical_alarm_active"
OPTICAL_ALARM_SELECTION = "optical_alarm_selection"
OPTIMUM_START_STOP = "optimum_start_stop"
PARTY_MODE = "party_mode"
POWER = "power"
PROGRAM = "program"
Expand All @@ -134,5 +135,6 @@ class Field(Enum):
TEMPERATURE = "temperature"
TEMPERATURE_MAXIMUM = "temperature_maximum"
TEMPERATURE_MINIMUM = "temperature_minimum"
TEMPERATURE_OFFSET = "temperature_offset"
VALVE_STATE = "valve_state"
VOLTAGE = "voltage"
6 changes: 6 additions & 0 deletions hahomematic/platforms/custom/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,13 @@
Field.ACTIVE_PROFILE: Parameter.ACTIVE_PROFILE,
Field.BOOST_MODE: Parameter.BOOST_MODE,
Field.CONTROL_MODE: Parameter.CONTROL_MODE,
Field.OPTIMUM_START_STOP: Parameter.OPTIMUM_START_STOP,
Field.PARTY_MODE: Parameter.PARTY_MODE,
Field.SETPOINT: Parameter.SET_POINT_TEMPERATURE,
Field.SET_POINT_MODE: Parameter.SET_POINT_MODE,
Field.TEMPERATURE_MAXIMUM: Parameter.TEMPERATURE_MAXIMUM,
Field.TEMPERATURE_MINIMUM: Parameter.TEMPERATURE_MINIMUM,
Field.TEMPERATURE_OFFSET: Parameter.TEMPERATURE_OFFSET,
},
ED.VISIBLE_REPEATABLE_FIELDS: {
Field.HEATING_COOLING: Parameter.HEATING_COOLING,
Expand All @@ -338,11 +340,13 @@
Field.ACTIVE_PROFILE: Parameter.ACTIVE_PROFILE,
Field.BOOST_MODE: Parameter.BOOST_MODE,
Field.CONTROL_MODE: Parameter.CONTROL_MODE,
Field.OPTIMUM_START_STOP: Parameter.OPTIMUM_START_STOP,
Field.PARTY_MODE: Parameter.PARTY_MODE,
Field.SETPOINT: Parameter.SET_POINT_TEMPERATURE,
Field.SET_POINT_MODE: Parameter.SET_POINT_MODE,
Field.TEMPERATURE_MAXIMUM: Parameter.TEMPERATURE_MAXIMUM,
Field.TEMPERATURE_MINIMUM: Parameter.TEMPERATURE_MINIMUM,
Field.TEMPERATURE_OFFSET: Parameter.TEMPERATURE_OFFSET,
},
ED.VISIBLE_REPEATABLE_FIELDS: {
Field.HEATING_COOLING: Parameter.HEATING_COOLING,
Expand Down Expand Up @@ -478,6 +482,7 @@
Field.SETPOINT: Parameter.SET_TEMPERATURE,
Field.TEMPERATURE_MAXIMUM: Parameter.TEMPERATURE_MAXIMUM,
Field.TEMPERATURE_MINIMUM: Parameter.TEMPERATURE_MINIMUM,
Field.TEMPERATURE_OFFSET: Parameter.TEMPERATURE_OFFSET,
},
ED.VISIBLE_REPEATABLE_FIELDS: {
Field.HUMIDITY: Parameter.ACTUAL_HUMIDITY,
Expand All @@ -502,6 +507,7 @@
Field.SETPOINT: Parameter.SET_TEMPERATURE,
Field.TEMPERATURE_MAXIMUM: Parameter.TEMPERATURE_MAXIMUM,
Field.TEMPERATURE_MINIMUM: Parameter.TEMPERATURE_MINIMUM,
Field.TEMPERATURE_OFFSET: Parameter.TEMPERATURE_OFFSET,
},
ED.VISIBLE_REPEATABLE_FIELDS: {
Field.HUMIDITY: Parameter.ACTUAL_HUMIDITY,
Expand Down
Loading

0 comments on commit 7a2dd39

Please sign in to comment.