本文整理汇总了Python中Resource.create_temp_sensor方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.create_temp_sensor方法的具体用法?Python Resource.create_temp_sensor怎么用?Python Resource.create_temp_sensor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource
的用法示例。
在下文中一共展示了Resource.create_temp_sensor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import Resource [as 别名]
# 或者: from Resource import create_temp_sensor [as 别名]
def main(self):
logging.info("Incubator started... " + self.start_time.strftime('%Y-%m-%d %H:%M:%S'))
self.send_notification("Incubator started")
self.ssr.set_point(self.config.get_temp())
# Start roller
self.roller.set_day(self.config.get_day())
self.roller.start()
web = Web.Web(self)
web.start()
lcd = Lcd()
temp_sensor = Resource.create_temp_sensor()
htu21d = Resource.create_humidity_sensor()
# Start SSR service
self.ssr.set_value(0)
self.ssr.start()
# Start buttons and relays
# self.io_handler.start()
i = 0
state = State()
state.set_day(self.get_days_from_start())
http_sender = HttpSender.HttpSender()
while self._running:
state.update_ts()
state.set_temp1(temp_sensor.read_temp())
pid = self.ssr.update(state.get_temp1())
state.set_pid(pid)
#if state.temp1 > 38.5:
# self.send_notification("High temp alert, {} gr".format(state.temp1))
if i % 10 == 0:
# Read humidity and temp each 10 seconds
try:
state.set_temp2(htu21d.read_temperature())
state.set_humidity(htu21d.read_humidity())
except:
self.send_notification("Failed to read htu21d")
self.ventilation.set_state(state)
state.set_humidity_level(self.ventilation.get_output_level())
http_sender.send("A123", state)
if i >= 30:
# Set new temp from config file
self.config.reload()
self.ssr.set_point(self.config.get_temp())
self.ssr.set_k(self.config.get_k())
self.ssr.set_i(self.config.get_i())
self.ventilation.set_point(self.get_humidity())
state.set_day(self.get_days_from_start())
if self.config.get_day() != state.get_day():
self.config.set_day(state.get_day())
self.config.save()
self.roller.set_day(state.get_day())
self.log_incubator_state(self.config, state)
# update web page
web.update(state, self.config)
i = 0
lcd.update(state, self.roller.get_minutes_from_last_roll())
sys.stdout.flush()
time.sleep(1)
i += 1
self.shutdown()