diff service/piNode/devices.py @ 381:38a74c43639c

defer import of w1thermsensor Ignore-this: 9fcf8a4313599bace8315f943c145f41
author drewp@bigasterisk.com
date Fri, 28 Dec 2018 01:56:33 -0800
parents 194583bd603e
children 864c8911ae73
line wrap: on
line diff
--- a/service/piNode/devices.py	Tue Dec 18 23:56:12 2018 -0800
+++ b/service/piNode/devices.py	Fri Dec 28 01:56:33 2018 -0800
@@ -18,7 +18,6 @@
     import pigpio
 except ImportError:
     pigpio = None
-import w1thermsensor
 try:
     import rpi_ws281x
 except ImportError:
@@ -359,7 +358,9 @@
     # deliberately written like arduinoNode's one for an easier merge.
     def __init__(self,  *a, **kw):
         DeviceType.__init__(self, *a, **kw)
+        import w1thermsensor
         log.info("scan for w1 devices")
+        self.SensorNotReadyError = w1thermsensor.core.SensorNotReadyError
         self._sensors = w1thermsensor.W1ThermSensor.get_available_sensors()
         for s in self._sensors:
             # Something looks different about these ids
@@ -379,7 +380,7 @@
                     stmts.append((sensor.uri, ROOM['temperatureF'],
                                   # see round() note in arduinoNode/devices.py
                                   Literal(round(tempF, 2))))
-                except w1thermsensor.core.SensorNotReadyError as e:
+                except self.SensorNotReadyError as e:
                     log.warning(e)
 
             return stmts