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

Save last target temperature in Shelly climate platform #80561

Merged
merged 1 commit into from
Oct 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions homeassistant/components/shelly/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(
self.last_state: State | None = None
self.last_state_attributes: Mapping[str, Any]
self._preset_modes: list[str] = []
self._last_target_temp = 20.0

if self.block is not None and self.device_block is not None:
self._unique_id = f"{self.coordinator.mac}-{self.block.description}"
Expand Down Expand Up @@ -260,9 +261,15 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set hvac mode."""
if hvac_mode == HVACMode.OFF:
if isinstance(self.target_temperature, float):
self._last_target_temp = self.target_temperature
await self.set_state_full_path(
target_t_enabled=1, target_t=f"{self._attr_min_temp}"
)
if hvac_mode == HVACMode.HEAT:
await self.set_state_full_path(
target_t_enabled=1, target_t=self._last_target_temp
)

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set preset mode."""
Expand Down