Gracefully handle missing preset mode in Tuya fan (#62996)

This commit is contained in:
Franck Nijhof 2021-12-29 15:34:36 +01:00
parent ac92a7f425
commit e5c5a73349
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

@ -160,9 +160,9 @@ class TuyaFanEntity(TuyaEntity, FanEntity):
return self.ha_preset_modes
@property
def preset_mode(self) -> str:
def preset_mode(self) -> str | None:
"""Return the current preset_mode."""
return self.device.status[DPCode.MODE]
return self.device.status.get(DPCode.MODE)
@property
def percentage(self) -> int | None: