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

This commit is contained in:
Franck Nijhof 2021-12-29 15:34:36 +01:00 committed by GitHub
parent 497bfc1c8f
commit 084e81f827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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: