Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix set_hvac_mode for systems w/o DHW #85

Merged
merged 1 commit into from Feb 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions custom_components/vicare/climate.py
Expand Up @@ -84,6 +84,12 @@
HVAC_MODE_AUTO: VICARE_MODE_DHWANDHEATING,
}

HA_TO_VICARE_HVAC_HEATING_ALT = {
HVAC_MODE_HEAT: VICARE_MODE_HEATING,
HVAC_MODE_OFF: VICARE_MODE_OFF,
HVAC_MODE_AUTO: VICARE_MODE_HEATING,
}

VICARE_TO_HA_PRESET_HEATING = {
VICARE_PROGRAM_COMFORT: PRESET_COMFORT,
VICARE_PROGRAM_ECO: PRESET_ECO,
Expand Down Expand Up @@ -278,6 +284,16 @@ def set_hvac_mode(self, hvac_mode):
f"Cannot set invalid vicare mode: {hvac_mode} / {vicare_mode}"
)

supported_modes = self._attributes["vicare_modes"]
# Alternative heating modes
if vicare_mode not in supported_modes:
vicare_mode = HA_TO_VICARE_HVAC_HEATING_ALT.get(hvac_mode)

if vicare_mode not in supported_modes:
raise ValueError(
f"No supported vicare mode found for {hvac_mode} in {supported_modes}"
)

_LOGGER.debug("Setting hvac mode to %s / %s", hvac_mode, vicare_mode)
self._circuit.setMode(vicare_mode)

Expand Down