Skip to content

Commit

Permalink
🔥 add aux heat for climate
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Feb 22, 2025
1 parent 4bec329 commit 87bd175
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions custom_components/xiaomi_miot/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class BaseClimateEntity(BaseEntity):
_attr_swing_horizontal_mode = None
_attr_swing_horizontal_modes = None
_attr_temperature_unit = None
_attr_is_aux_heat = None

def on_init(self):
self._attr_hvac_modes = []
Expand Down Expand Up @@ -160,6 +161,7 @@ class ClimateEntity(XEntity, BaseClimateEntity):
_conv_speed = None
_conv_swing = None
_conv_swing_h = None
_conv_heater = None
_conv_target_temp = None
_conv_current_temp = None
_conv_target_humidity = None
Expand Down Expand Up @@ -210,6 +212,9 @@ def on_init(self):
self._conv_swing_h = conv
self._attr_swing_horizontal_modes = [SWING_ON, SWING_OFF]
self._attr_supported_features |= ClimateEntityFeature.SWING_HORIZONTAL_MODE
elif prop.in_list(['heater']):
self._conv_heater = conv
self._attr_supported_features |= ClimateEntityFeature.AUX_HEAT
elif prop.in_list(['target_temperature']):
self._conv_target_temp = conv
self._attr_min_temp = prop.range_min()
Expand Down Expand Up @@ -265,6 +270,10 @@ def set_state(self, data: dict):
self._attr_swing_horizontal_mode = SWING_ON if val else SWING_OFF

self.update_bind_sensor()
if self._conv_heater:
val = self._conv_heater.value_from_dict(data)
if val is not None:
self._attr_is_aux_heat = val in [True, 1, 'On']
if self._conv_target_temp:
val = self._conv_target_temp.value_from_dict(data)
if val is not None:
Expand Down Expand Up @@ -363,6 +372,16 @@ async def async_set_swing_horizontal_mode(self, swing_horizontal_mode: str):
return
await self.device.async_write({self._conv_swing_h.full_name: swing_horizontal_mode == SWING_ON})

async def async_turn_aux_heat_on(self):
if not self._conv_heater:
return
await self.device.async_write({self._conv_heater.full_name: True})

async def async_turn_aux_heat_off(self):
if not self._conv_heater:
return
await self.device.async_write({self._conv_heater.full_name: False})

XEntity.CLS[ENTITY_DOMAIN] = ClimateEntity


Expand Down

0 comments on commit 87bd175

Please sign in to comment.