def submit_data(sensor_type,sensor_id,sensor_param,param_value):
global submit_time
def submit_data(sensor_type,sensor_id,sensor_param,param_value):
global submit_time
global submit_queue
c = database.cursor()
c.execute('CALL meteo.submit_value(%s,%s,%s,%s,NULL)', (sensor_type,sensor_id,sensor_param,param_value))
database.commit()
submit_queue[sensor_type+'.'+sensor_id+'.'+sensor_param]={'val':param_value,'timestamp':time()}
if time()>submit_time+external_submit_interval:
global submit_queue
c = database.cursor()
c.execute('CALL meteo.submit_value(%s,%s,%s,%s,NULL)', (sensor_type,sensor_id,sensor_param,param_value))
database.commit()
submit_queue[sensor_type+'.'+sensor_id+'.'+sensor_param]={'val':param_value,'timestamp':time()}
if time()>submit_time+external_submit_interval:
- if submit_narodmon(submit_queue):
- if owmuser:
- submit_owm(submit_queue)
- print_log('Purging queue...')
- submit_time=time()
- purge_queue()
+ submit_narodmon(submit_queue)
+ submit_time=time()
+ if owmuser and time()>submit_time_owm+owm_submit_interval:
+ submit_owm(submit_queue)
+ submit_time_owm=time()
+ purge_queue()