mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Add new climate feature flags to tuya (#109434)
This commit is contained in:
parent
37f3fcbdaf
commit
6e5a085413
@ -127,6 +127,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
|
|||||||
_set_temperature: IntegerTypeData | None = None
|
_set_temperature: IntegerTypeData | None = None
|
||||||
entity_description: TuyaClimateEntityDescription
|
entity_description: TuyaClimateEntityDescription
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
|
_enable_turn_on_off_backwards_compatibility = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -277,6 +278,11 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
|
|||||||
if self.find_dpcode(DPCode.SWITCH_VERTICAL, prefer_function=True):
|
if self.find_dpcode(DPCode.SWITCH_VERTICAL, prefer_function=True):
|
||||||
self._attr_swing_modes.append(SWING_VERTICAL)
|
self._attr_swing_modes.append(SWING_VERTICAL)
|
||||||
|
|
||||||
|
if DPCode.SWITCH in self.device.function:
|
||||||
|
self._attr_supported_features |= (
|
||||||
|
ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
|
||||||
|
)
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Call when entity is added to hass."""
|
"""Call when entity is added to hass."""
|
||||||
await super().async_added_to_hass()
|
await super().async_added_to_hass()
|
||||||
@ -476,23 +482,8 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
|
|||||||
|
|
||||||
def turn_on(self) -> None:
|
def turn_on(self) -> None:
|
||||||
"""Turn the device on, retaining current HVAC (if supported)."""
|
"""Turn the device on, retaining current HVAC (if supported)."""
|
||||||
if DPCode.SWITCH in self.device.function:
|
self._send_command([{"code": DPCode.SWITCH, "value": True}])
|
||||||
self._send_command([{"code": DPCode.SWITCH, "value": True}])
|
|
||||||
return
|
|
||||||
|
|
||||||
# Fake turn on
|
|
||||||
for mode in (HVACMode.HEAT_COOL, HVACMode.HEAT, HVACMode.COOL):
|
|
||||||
if mode not in self.hvac_modes:
|
|
||||||
continue
|
|
||||||
self.set_hvac_mode(mode)
|
|
||||||
break
|
|
||||||
|
|
||||||
def turn_off(self) -> None:
|
def turn_off(self) -> None:
|
||||||
"""Turn the device on, retaining current HVAC (if supported)."""
|
"""Turn the device on, retaining current HVAC (if supported)."""
|
||||||
if DPCode.SWITCH in self.device.function:
|
self._send_command([{"code": DPCode.SWITCH, "value": False}])
|
||||||
self._send_command([{"code": DPCode.SWITCH, "value": False}])
|
|
||||||
return
|
|
||||||
|
|
||||||
# Fake turn off
|
|
||||||
if HVACMode.OFF in self.hvac_modes:
|
|
||||||
self.set_hvac_mode(HVACMode.OFF)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user