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

Handle preset change errors in ViCare integration #103992

Merged
merged 12 commits into from
Nov 27, 2023
17 changes: 12 additions & 5 deletions homeassistant/components/vicare/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,23 @@ def set_preset_mode(self, preset_mode: str) -> None:
f"Cannot set invalid vicare program: {preset_mode}/{vicare_program}"
edenhaus marked this conversation as resolved.
Show resolved Hide resolved
)

_LOGGER.debug("Setting preset to %s / %s", preset_mode, vicare_program)
_LOGGER.debug("Current preset %s", self._current_program)
if self._current_program != VICARE_PROGRAM_NORMAL:
# We can't deactivate "normal"
# We can't deactivate "normal" or "reduced"
edenhaus marked this conversation as resolved.
Show resolved Hide resolved
_LOGGER.debug("deactivating %s", self._current_program)
try:
self._circuit.deactivateProgram(self._current_program)
except PyViCareCommandError:
_LOGGER.debug("Unable to deactivate program %s", self._current_program)
_LOGGER.error("Unable to deactivate program %s", self._current_program)

_LOGGER.debug("Setting preset to %s / %s", preset_mode, vicare_program)
if vicare_program != VICARE_PROGRAM_NORMAL:
CFenner marked this conversation as resolved.
Show resolved Hide resolved
# And we can't explicitly activate normal, either
self._circuit.activateProgram(vicare_program)
# And we can't explicitly activate "normal" or "reduced", either
_LOGGER.debug("activating %s", vicare_program)
try:
self._circuit.activateProgram(vicare_program)
except PyViCareCommandError:
_LOGGER.error("Unable to activate program %s", vicare_program)

@property
def extra_state_attributes(self):
Expand Down