Skip to content

Commit

Permalink
Add preset mode to LWZ
Browse files Browse the repository at this point in the history
  • Loading branch information
pail23 committed Nov 24, 2023
1 parent ecceb72 commit b77b165
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
42 changes: 42 additions & 0 deletions custom_components/stiebel_eltron_isg/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
PRESET_WATER_HEATING = "water_heating"
PRESET_EMERGENCY = "emergency"
PRESET_READY = "ready"
PRESET_MANUAL = "manual"
PRESET_AUTO = "auto"


WPM_TO_HA_PRESET = {
1: PRESET_READY,
Expand Down Expand Up @@ -93,6 +96,26 @@
HVACMode.HEAT: 14,
}

LWZ_TO_HA_PRESET = {
1: PRESET_READY,
3: PRESET_COMFORT,
4: PRESET_ECO,
5: PRESET_WATER_HEATING,
11: PRESET_AUTO,
14: PRESET_MANUAL,
0: PRESET_EMERGENCY,
}

HA_TO_LWZ_PRESET = {
PRESET_READY: 1,
PRESET_COMFORT: 3,
PRESET_ECO: 4,
PRESET_WATER_HEATING: 5,
PRESET_AUTO: 11,
PRESET_MANUAL: 14,
PRESET_EMERGENCY: 0,
}

LWZ_TO_HA_FAN = {0: FAN_OFF, 1: FAN_LOW, 2: FAN_MEDIUM, 3: FAN_HIGH}
HA_TO_LWZ_FAN = {k: i for i, k in LWZ_TO_HA_FAN.items()}

Expand Down Expand Up @@ -242,6 +265,15 @@ class StiebelEltronLWZClimateEntity(StiebelEltronISGClimateEntity):
def __init__(self, coordinator, config_entry, description):
"""Initialize the climate entity."""
self._attr_hvac_modes = [HVACMode.AUTO, HVACMode.OFF, HVACMode.HEAT]
self._attr_preset_modes = [
PRESET_READY,
PRESET_AUTO,
PRESET_MANUAL,
PRESET_ECO,
PRESET_COMFORT,
PRESET_WATER_HEATING,
PRESET_EMERGENCY,
]
self._attr_fan_modes = [FAN_OFF, FAN_LOW, FAN_MEDIUM, FAN_HIGH]
super().__init__(coordinator, config_entry, description)
self._attr_supported_features = (
Expand All @@ -258,6 +290,16 @@ def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
new_mode = HA_TO_LWZ_HVAC.get(hvac_mode)
self.coordinator.set_data(OPERATION_MODE, new_mode)

@property
def preset_mode(self) -> str | None:
"""Return current preset mode."""
return LWZ_TO_HA_PRESET.get(self.coordinator.data.get(OPERATION_MODE))

def set_preset_mode(self, preset_mode):
"""Set new target preset mode."""
new_mode = HA_TO_LWZ_PRESET.get(preset_mode)
self.coordinator.set_data(OPERATION_MODE, new_mode)

@property
def fan_mode(self) -> str | None:
"""Return the fan setting. Requires ClimateEntityFeature.FAN_MODE."""
Expand Down
4 changes: 3 additions & 1 deletion custom_components/stiebel_eltron_isg/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"water_heating": "Water heating",
"emergency": "Emergency",
"program": "Program",
"ready": "Ready"
"ready": "Ready",
"auto": "Auto",
"manual": "Manual"
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion custom_components/stiebel_eltron_isg/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"water_heating": "Warmwasserbetrieb",
"emergency": "Notbetrieb",
"program": "Programmbetrieb",
"ready": "Bereitschaftsbetrieb"
"ready": "Bereitschaftsbetrieb",
"auto": "Autobetrieb",
"manual": "Handbetrieb"
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion custom_components/stiebel_eltron_isg/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"water_heating": "Water heating",
"emergency": "Emergency",
"program": "Program",
"ready": "Ready"
"ready": "Ready",
"auto": "Auto",
"manual": "Manual"
}
}
}
Expand Down

0 comments on commit b77b165

Please sign in to comment.