mirror of
https://gitee.com/qpy-solutions/tracker-v2.git
synced 2025-05-19 11:08:26 +08:00
update: tempreature and humidity check and get
This commit is contained in:
parent
873d898ade
commit
5dca1ab0f3
@ -305,12 +305,13 @@ class Collector(Singleton):
|
|||||||
|
|
||||||
def __get_temp_humidity(self):
|
def __get_temp_humidity(self):
|
||||||
data = {}
|
data = {}
|
||||||
on_res = self.__temp_humidity_sensor.on()
|
if self.__temp_humidity_sensor is not None:
|
||||||
if on_res:
|
on_res = self.__temp_humidity_sensor.on()
|
||||||
temperature, humidity = self.__temp_humidity_sensor.read()
|
if on_res:
|
||||||
data["temperature"] = temperature
|
temperature, humidity = self.__temp_humidity_sensor.read()
|
||||||
data["humidity"] = humidity
|
data["temperature"] = temperature
|
||||||
self.__temp_humidity_sensor.off()
|
data["humidity"] = humidity
|
||||||
|
self.__temp_humidity_sensor.off()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def add_module(self, module):
|
def add_module(self, module):
|
||||||
|
@ -90,11 +90,14 @@ class DeviceCheck(object):
|
|||||||
def temp(self):
|
def temp(self):
|
||||||
# return True if OK
|
# return True if OK
|
||||||
res = False
|
res = False
|
||||||
if self.__temp_humidity.on():
|
if self.__temp_humidity is None:
|
||||||
temperature, humidity = self.__temp_humidity.read()
|
res = None
|
||||||
if temperature is not None and humidity is not None:
|
else:
|
||||||
res = True
|
if self.__temp_humidity.on():
|
||||||
self.__temp_humidity.off()
|
temperature, humidity = self.__temp_humidity.read()
|
||||||
|
if temperature is not None and humidity is not None:
|
||||||
|
res = True
|
||||||
|
self.__temp_humidity.off()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def light(self):
|
def light(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user