From e137d598f0eb9873829a1cf70bbec58b1ea2b84d Mon Sep 17 00:00:00 2001 From: ThomasADavis Date: Sun, 15 Nov 2020 09:49:08 -0800 Subject: [PATCH] This makes sure that any scaling is only applied to numeric values. (#154) * This makes sure that any scaling is only applied to numeric values. * Updates fan controller. This adds support for 3 speed fans, 4 speeds fan (with choice of 3 of the 4 speeds), fans speed of 1,2,3,4 or low,medium,mid,high, and auto. Fans that have variable speeds, or greater than 4 speeds is not supported at this time. HA does not support variable speed fans and more than 3 speeds. * Revert "Updates fan controller." This reverts commit 00352da2de72d02977d8a7d3780aabf4f28ee0fa. Co-authored-by: Thomas Davis --- custom_components/localtuya/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/localtuya/sensor.py b/custom_components/localtuya/sensor.py index f1ed21e..bd73814 100644 --- a/custom_components/localtuya/sensor.py +++ b/custom_components/localtuya/sensor.py @@ -62,7 +62,7 @@ class LocaltuyaSensor(LocalTuyaEntity): """Device status was updated.""" state = self.dps(self._dp_id) scale_factor = self._config.get(CONF_SCALING) - if scale_factor is not None: + if scale_factor is not None and isinstance(state, (int, float)): state = round(state * scale_factor, DEFAULT_PRECISION) self._state = state