def vibrate_phone(msg): connection, login_info = get_connection() stuff = { "secret": login_info['secret'], "to": login_info['to'], "device": None, "payload": msg } requests.post('https://llamalab.com/automate/cloud/message', data=stuff)
def get_data(): connection, login_info = get_connection() with connection.cursor() as cursor: sql = """ select date_time as dt, temp0, temp1, temp2, temp3 from recorded_data where smoke_session_id = {} """.format(Smoke_Session_ID) cursor.execute(sql) result = pd.DataFrame(cursor.fetchall()) connection.close() return result
def on_click(n_clicks): connection, login_info = get_connection() smoke_session_id = get_last_smoke_session_id(connection) df = read_data('recorded_data', smoke_session_id, connection) data = [ dict(x=df['date_time'], y=df['temp0'], text='smoker', name='smoker'), dict(x=df['date_time'], y=df['temp1'], text='meat1', name='meat1'), dict(x=df['date_time'], y=df['temp2'], text='meat2', name='meat2') ] layout = dict(xaxis={'title': 'time'}, yaxis={'title': 'temp'}, legend={ 'x': 0, 'y': 1 }, hovermode='closest') df = None return {'data': data, 'layout': layout}
write_new_ss(new_ss, connection) smoke_session_id = get_last_smoke_session_id(connection) thermistor_version = input("Which thermistors are you using? (old/new): ") return smoke_session_id, thermistor_version ######################################################################################## if __name__ == "__main__": adcs = {} connection, login_info = get_connection() smoke_session_id, thermistor_version = check_smoke_session(connection) while True: print('Start') # temp_percent = get_temp_percent() temp_percent = get_adc_value() resistance = get_resistance(temp_percent=temp_percent) temp = get_temp(R=resistance, thermistor_version=thermistor_version) temp = temp.tolist() temp = ['null' if (np.isnan(_)) else _ for _ in temp]