From 6023fd3db3bf8a4639b6a7d95507adf434c6e7f3 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 28 Nov 2021 15:11:20 +0100 Subject: [PATCH] Given the new object-oriented design of the LTR559 library, the sensor object should be initialized in __init__ and read upon get_measurement() --- platypush/plugins/gpio/sensor/ltr559/__init__.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/platypush/plugins/gpio/sensor/ltr559/__init__.py b/platypush/plugins/gpio/sensor/ltr559/__init__.py index ff74e0c00..2ed58b813 100644 --- a/platypush/plugins/gpio/sensor/ltr559/__init__.py +++ b/platypush/plugins/gpio/sensor/ltr559/__init__.py @@ -13,7 +13,9 @@ class GpioSensorLtr559Plugin(GpioSensorPlugin): """ def __init__(self, **kwargs): + import ltr559 super().__init__(**kwargs) + self.ltr = ltr559.LTR559() # noinspection PyUnresolvedReferences @action @@ -29,14 +31,10 @@ class GpioSensorLtr559Plugin(GpioSensorPlugin): } """ - - import ltr559 - ltr = ltr559.LTR559() - ltr.update_sensor() - + self.ltr.update_sensor() return { - 'light': ltr.get_lux(), - 'proximity': ltr.get_proximity(), + 'light': self.ltr.get_lux(), + 'proximity': self.ltr.get_proximity(), }