Clean up self references from Tuya climate platform constructor (#58051)

This commit is contained in:
Franck Nijhof 2021-10-19 21:04:46 +02:00 committed by GitHub
parent d2f7f418c3
commit bc9b134c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -252,7 +252,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
): ):
self._current_humidity_dpcode = DPCode.HUMIDITY_CURRENT self._current_humidity_dpcode = DPCode.HUMIDITY_CURRENT
self._current_humidity_type = IntegerTypeData.from_json( self._current_humidity_type = IntegerTypeData.from_json(
self.device.status_range[DPCode.HUMIDITY_CURRENT].values device.status_range[DPCode.HUMIDITY_CURRENT].values
) )
# Determine dpcode to use for getting the current humidity # Determine dpcode to use for getting the current humidity
@ -262,7 +262,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
): ):
self._current_humidity_dpcode = DPCode.HUMIDITY_CURRENT self._current_humidity_dpcode = DPCode.HUMIDITY_CURRENT
self._current_humidity_type = IntegerTypeData.from_json( self._current_humidity_type = IntegerTypeData.from_json(
self.device.status_range[DPCode.HUMIDITY_CURRENT].values device.status_range[DPCode.HUMIDITY_CURRENT].values
) )
# Determine fan modes # Determine fan modes
@ -272,12 +272,12 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
): ):
self._attr_supported_features |= SUPPORT_FAN_MODE self._attr_supported_features |= SUPPORT_FAN_MODE
self._attr_fan_modes = EnumTypeData.from_json( self._attr_fan_modes = EnumTypeData.from_json(
self.device.status_range[DPCode.FAN_SPEED_ENUM].values device.status_range[DPCode.FAN_SPEED_ENUM].values
).range ).range
# Determine swing modes # Determine swing modes
if any( if any(
dpcode in self.device.function dpcode in device.function
for dpcode in ( for dpcode in (
DPCode.SHAKE, DPCode.SHAKE,
DPCode.SWING, DPCode.SWING,
@ -288,15 +288,14 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
self._attr_supported_features |= SUPPORT_SWING_MODE self._attr_supported_features |= SUPPORT_SWING_MODE
self._attr_swing_modes = [SWING_OFF] self._attr_swing_modes = [SWING_OFF]
if any( if any(
dpcode in self.device.function dpcode in device.function for dpcode in (DPCode.SHAKE, DPCode.SWING)
for dpcode in (DPCode.SHAKE, DPCode.SWING)
): ):
self._attr_swing_modes.append(SWING_ON) self._attr_swing_modes.append(SWING_ON)
if DPCode.SWITCH_HORIZONTAL in self.device.function: if DPCode.SWITCH_HORIZONTAL in device.function:
self._attr_swing_modes.append(SWING_HORIZONTAL) self._attr_swing_modes.append(SWING_HORIZONTAL)
if DPCode.SWITCH_VERTICAL in self.device.function: if DPCode.SWITCH_VERTICAL in device.function:
self._attr_swing_modes.append(SWING_VERTICAL) self._attr_swing_modes.append(SWING_VERTICAL)
def set_hvac_mode(self, hvac_mode: str) -> None: def set_hvac_mode(self, hvac_mode: str) -> None: