From 8462f474f733fa3c7d124520bb365d26eba37dc7 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 14 Aug 2019 22:49:18 +0200 Subject: [PATCH] Skip tolerance check whether if the new or the old value are not numeric --- platypush/backend/sensor/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platypush/backend/sensor/__init__.py b/platypush/backend/sensor/__init__.py index 522b3b46..04780e56 100644 --- a/platypush/backend/sensor/__init__.py +++ b/platypush/backend/sensor/__init__.py @@ -123,6 +123,7 @@ class SensorBackend(Backend): try: v = float(v) + old_v = float(self.data.get(k)) except (TypeError, ValueError): isNaN = True @@ -136,7 +137,7 @@ class SensorBackend(Backend): pass if tolerance is None or isNaN or \ - abs(v - self.data.get(k)) >= tolerance: + abs(v - old_v) >= tolerance: ret[k] = v return ret