Skip to content

Commit

Permalink
Merge pull request #211 from dingausmwald/patch-1
Browse files Browse the repository at this point in the history
Update climate.py
  • Loading branch information
tschamm authored Jan 11, 2025
2 parents d55f069 + fefb57e commit 472bc0f
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions custom_components/bosch_shc/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class ClimateControl(SHCEntity, ClimateEntity):

_attr_target_temperature_step = 0.5
_attr_supported_features = (
ClimateEntityFeature.TURN_ON
| ClimateEntityFeature.TURN_OFF
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.TURN_OFF
| ClimateEntityFeature.TURN_ON
)
_enable_turn_on_off_backwards_compatibility = False

Expand Down Expand Up @@ -148,8 +148,11 @@ def preset_modes(self):
@property
def supported_features(self) -> ClimateEntityFeature:
"""Return supported features."""
return ClimateEntityFeature(
ClimateEntityFeature.TARGET_TEMPERATURE + ClimateEntityFeature.PRESET_MODE
return (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.TURN_OFF
| ClimateEntityFeature.TURN_ON
)

def set_temperature(self, **kwargs):
Expand All @@ -172,25 +175,37 @@ def set_temperature(self, **kwargs):
if self.min_temp <= temperature <= self.max_temp:
self._device.setpoint_temperature = float(round(temperature * 2.0) / 2.0)

def set_hvac_mode(self, hvac_mode: str):
async def async_set_hvac_mode(self, hvac_mode: str):
"""Set hvac mode."""
if hvac_mode not in self.hvac_modes:
return
if self.preset_mode == PRESET_ECO:
return

if hvac_mode == HVACMode.AUTO:
self._device.summer_mode = False
self._device.operation_mode = (
await self.hass.async_add_executor_job(
setattr, self._device, "summer_mode", False
)
await self.hass.async_add_executor_job(
setattr,
self._device,
"operation_mode",
SHCClimateControl.RoomClimateControlService.OperationMode.AUTOMATIC
)
if hvac_mode == HVACMode.HEAT:
self._device.summer_mode = False
self._device.operation_mode = (
await self.hass.async_add_executor_job(
setattr, self._device, "summer_mode", False
)
await self.hass.async_add_executor_job(
setattr,
self._device,
"operation_mode",
SHCClimateControl.RoomClimateControlService.OperationMode.MANUAL
)
if hvac_mode == HVACMode.OFF:
self._device.summer_mode = True
await self.hass.async_add_executor_job(
setattr, self._device, "summer_mode", True
)

def set_preset_mode(self, preset_mode: str):
"""Set preset mode."""
Expand Down Expand Up @@ -219,3 +234,13 @@ def set_preset_mode(self, preset_mode: str):

if not self._device.low:
self._device.low = True

async def async_turn_on(self) -> None:
"""Turn the climate device on."""
if self.hvac_mode == HVACMode.OFF:
await self.async_set_hvac_mode(HVACMode.HEAT)

async def async_turn_off(self) -> None:
"""Turn the climate device off."""
if self.hvac_mode != HVACMode.OFF:
await self.async_set_hvac_mode(HVACMode.OFF)

0 comments on commit 472bc0f

Please sign in to comment.