From 876a07d2c8f9f53c232f17dc83dd0d9d77624b34 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 24 Sep 2019 10:00:56 +0200 Subject: [PATCH] Keep measurements in a loop until we get a valid data point --- platypush/plugins/gpio/sensor/motion/pwm3901.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platypush/plugins/gpio/sensor/motion/pwm3901.py b/platypush/plugins/gpio/sensor/motion/pwm3901.py index 6398142c37..4d62e7ee44 100644 --- a/platypush/plugins/gpio/sensor/motion/pwm3901.py +++ b/platypush/plugins/gpio/sensor/motion/pwm3901.py @@ -94,12 +94,12 @@ class GpioSensorMotionPwm3901Plugin(GpioSensorPlugin): sensor = self._get_sensor() - try: - x, y = sensor.get_motion() - except RuntimeError as e: - self.logger.warning('Unable to retrieve sensor data: {}'.format(e)) - self._sensor = None - return {}, str(e) + while True: + try: + x, y = sensor.get_motion() + break + except RuntimeError as e: + time.sleep(0.01) secs = int(time.time()) if (x, y) != (self.x, self.y):