Ejemplo n.º 1
0
def do_them_updates():
    tempfile = util.get_temp_file()
    tm = TempClient(tempfile)
    table = util.get_temp_hist_table()
    dc = DynamoClient(table)
    while (True):
        s_time = time.time()
        tm.refresh()
        temp = tm.get_temp()
        if (tm.has_temp()):
            dc.record_temperature(temp)
        sleep_time = 1 - (time.time() - s_time)
        sleep_time = max(sleep_time, 0.1)
        time.sleep(sleep_time)
Ejemplo n.º 2
0
def control_wemo():
  wc = WemoClient()
  dc = DynamoClient('miscellaneous')
  queue = Queue.Queue()
  queue_list = [queue]
  old_items = []
  dsc = DynamoStreamClient(queue_list, old_items, util.temp_hist_arn)
  dsc.start()
  try:
      while True:
        d = queue.get()
        max_temp = dc.get_max_temp()
        min_temp = dc.get_min_temp()
        temp = d['temperature']
        if temp > max_temp:
          wc.switch_off()
        elif temp < min_temp:
          wc.switch_on()
  finally:
    dsc.stop()
Ejemplo n.º 3
0
def main():
    table = util.get_temp_hist_table()
    dc = DynamoClient()
    temp = dc.get_latest_temperature()
    print(temp["temperature"])