def save_db_indoor(Indoor): with app.app_context(): db = get_db() db.execute('INSERT INTO indoor(node_number,update_time,temperature,humidity,radiation,co2) VALUES(?,?,?,?,?,?)', [Indoor.get_name(), Indoor.get_update_time(), Indoor.get_temperature(), Indoor.get_humidity(), Indoor.get_radiation(), Indoor.get_co2()]) db.commit() db.close() print 'indoor save success'
def save_db_indoor(Indoor): with app.app_context(): db = get_db() indoor_node = "indoor_node_" + Indoor.get_name() db.cursor().execute( 'insert into ' + indoor_node + '(node,update_time,temperature,humidity,radiation,co2) values(%s,%s,%s,%s,%s,%s)', [ Indoor.get_name(), get_current_time(), Indoor.get_temperature(), Indoor.get_humidity(), Indoor.get_radiation(), Indoor.get_co2() ]) db.commit() db.cursor().close() db.close() print 'indoor save success'
def co2(self, Indoor, Parameter, Control): if Indoor.get_co2() < Parameter.co2_lower_limit: Control.set_co2("on") elif Indoor.get_co2() > Parameter.co2_upper_limit: Control.set_co2("off")