Mercurial > code > home > repos > homeauto
comparison 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 |
comparison
equal
deleted
inserted
replaced
380:f78438913bf7 | 381:38a74c43639c |
---|---|
16 | 16 |
17 try: | 17 try: |
18 import pigpio | 18 import pigpio |
19 except ImportError: | 19 except ImportError: |
20 pigpio = None | 20 pigpio = None |
21 import w1thermsensor | |
22 try: | 21 try: |
23 import rpi_ws281x | 22 import rpi_ws281x |
24 except ImportError: | 23 except ImportError: |
25 rpi_ws281x = None | 24 rpi_ws281x = None |
26 | 25 |
357 deviceType = ROOM['OneWire'] | 356 deviceType = ROOM['OneWire'] |
358 pollPeriod = 2 | 357 pollPeriod = 2 |
359 # deliberately written like arduinoNode's one for an easier merge. | 358 # deliberately written like arduinoNode's one for an easier merge. |
360 def __init__(self, *a, **kw): | 359 def __init__(self, *a, **kw): |
361 DeviceType.__init__(self, *a, **kw) | 360 DeviceType.__init__(self, *a, **kw) |
361 import w1thermsensor | |
362 log.info("scan for w1 devices") | 362 log.info("scan for w1 devices") |
363 self.SensorNotReadyError = w1thermsensor.core.SensorNotReadyError | |
363 self._sensors = w1thermsensor.W1ThermSensor.get_available_sensors() | 364 self._sensors = w1thermsensor.W1ThermSensor.get_available_sensors() |
364 for s in self._sensors: | 365 for s in self._sensors: |
365 # Something looks different about these ids | 366 # Something looks different about these ids |
366 # ('000003a5a94c') vs the ones I get from arduino | 367 # ('000003a5a94c') vs the ones I get from arduino |
367 # ('2813bea50300003d'). Not sure if I'm parsing them | 368 # ('2813bea50300003d'). Not sure if I'm parsing them |
377 try: | 378 try: |
378 tempF = sensor.get_temperature(sensor.DEGREES_F) | 379 tempF = sensor.get_temperature(sensor.DEGREES_F) |
379 stmts.append((sensor.uri, ROOM['temperatureF'], | 380 stmts.append((sensor.uri, ROOM['temperatureF'], |
380 # see round() note in arduinoNode/devices.py | 381 # see round() note in arduinoNode/devices.py |
381 Literal(round(tempF, 2)))) | 382 Literal(round(tempF, 2)))) |
382 except w1thermsensor.core.SensorNotReadyError as e: | 383 except self.SensorNotReadyError as e: |
383 log.warning(e) | 384 log.warning(e) |
384 | 385 |
385 return stmts | 386 return stmts |
386 except Exception as e: | 387 except Exception as e: |
387 log.error(e) | 388 log.error(e) |