From 66bda00b6611bc1f723de09646f24ac443d5ef26 Mon Sep 17 00:00:00 2001 From: Jason Rumney Date: Mon, 11 Mar 2024 19:06:23 +0900 Subject: [PATCH] fan: handle edge case where percentage is None Some fans may have optional dp for speed. Avoid an error initialising by avoiding exceptions in that case. Issue #1513 --- custom_components/tuya_local/fan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/tuya_local/fan.py b/custom_components/tuya_local/fan.py index bdec9334ed..c817fbcc15 100644 --- a/custom_components/tuya_local/fan.py +++ b/custom_components/tuya_local/fan.py @@ -117,7 +117,7 @@ def percentage(self): return None r = self._speed_dps.range(self._device) val = self._speed_dps.get_value(self._device) - if r: + if r and val is not None: val = ranged_value_to_percentage(r, val) return val