def hvac_mode(self) -> HVACMode: """HVAC current mode.""" if self.device_block is None: return HVACMode(self.last_state.state) if self.last_state else HVACMode.OFF if self.device_block.mode is None or self._check_is_off(): return HVACMode.OFF return HVACMode.HEAT
def set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target operation mode.""" if hvac_mode == HVACMode.OFF: if self.is_on: self.turn_off() return if not self.is_on: self.turn_on() self._device.set_operation_mode(hvac_mode.upper())
@property def current_temperature(self) -> float | None: """Return the current temperature.""" return self.device["sensors"].get("temperature") @property def target_temperature(self) -> float | None: """Return the temperature we try to reach.""" return self.device["sensors"].get("setpoint") @property def hvac_mode(self) -> HVACMode: """Return HVAC operation ie. heat, cool mode.""" if (mode := self.device.get("mode")) is None or mode not in self.hvac_modes: return HVACMode.HEAT return HVACMode(mode) @property def hvac_action(self) -> HVACAction: """Return the current running hvac operation if supported.""" # When control_state is present, prefer this data if "control_state" in self.device: if self.device.get("control_state") == "cooling": return HVACAction.COOLING # Support preheating state as heating, until preheating is added as a separate state if self.device.get("control_state") in ["heating", "preheating"]: return HVACAction.HEATING else: heater_central_data = self.coordinator.data.devices[ self.coordinator.data.gateway["heater_id"] ]
async def async_set_temperature(self, **kwargs) -> None: """Set new target temperature.""" if hvac_mode := kwargs.get(ATTR_HVAC_MODE): await self.async_set_hvac_mode(HVACMode(hvac_mode))