From ff1fe3058b84187213046850bb2f500d10fa5617 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 24 Sep 2019 01:01:06 +0200 Subject: [PATCH] Don't fail hard in case of temporary sensor glitches --- platypush/plugins/gpio/sensor/motion/pwm3901.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/gpio/sensor/motion/pwm3901.py b/platypush/plugins/gpio/sensor/motion/pwm3901.py index 318585fab2..5870fbaf8e 100644 --- a/platypush/plugins/gpio/sensor/motion/pwm3901.py +++ b/platypush/plugins/gpio/sensor/motion/pwm3901.py @@ -89,7 +89,13 @@ class GpioSensorMotionPwm3901Plugin(GpioSensorPlugin): """ sensor = self._get_sensor() - x, y = sensor.get_motion() + + 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) return { 'motion_x': x,