correct indents
parent
90e446ce72
commit
b8911b7177
34
tri.py
34
tri.py
|
@ -104,7 +104,7 @@ def upload_osm(sensor_id,value):
|
|||
a = 2
|
||||
|
||||
# push options to internet
|
||||
push_count=15 # wait 5 cycles till upload to opensensemap
|
||||
push_count=5 # wait 5 cycles till upload to opensensemap
|
||||
push_counter=0
|
||||
push_vars=["temperature","humidity","pressure"]
|
||||
push_data={}
|
||||
|
@ -179,7 +179,8 @@ for i in range(len(channel_names)):
|
|||
ch_old=ch_val
|
||||
|
||||
while a > 1:
|
||||
# copy channel values to backup
|
||||
print(push_counter)
|
||||
# copy channel values to backup
|
||||
ch_old=ch_val.copy()
|
||||
|
||||
# set actual time
|
||||
|
@ -247,24 +248,17 @@ while a > 1:
|
|||
f1=open("/home/pi/log/data_{:d}.txt".format(int(timefile)),"a")
|
||||
payload={}
|
||||
for i in range(len(ch_val)):
|
||||
if ch_val[i] != ch_old[i]:
|
||||
f1.write(channel_names[i] + ":{0};".format(int(ch_val[i])))
|
||||
if channel_names[i] != "time":
|
||||
payload[channel_names[i]]=int(ch_val[i])
|
||||
if push_counter ==1 :
|
||||
if channel_names[i] == "temperature":
|
||||
upload_osm(sensebox_temp,ch_val[i]/1000)
|
||||
if channel_names[i] == "humidity":
|
||||
upload_osm(sensebox_hum,ch_val[i]/1000)
|
||||
if channel_names[i] == "pressure":
|
||||
upload_osm(sensebox_pres,ch_val[i]/1000)
|
||||
if channel_names[i] in push_vars:
|
||||
if push_counter == push_count:
|
||||
sense_data=int(push_data[channel_names[i]]/(100*push_count))/10
|
||||
upload_osm(sensebox_sid[channel_names[i],sense_data)
|
||||
push_data[channel_names[i]]=0
|
||||
else:
|
||||
push_data[channel_names[i]]=push_data[channel_names[i]]+ch_val[i]
|
||||
if ch_val[i] != ch_old[i]:
|
||||
f1.write(channel_names[i] + ":{0};".format(int(ch_val[i])))
|
||||
if channel_names[i] != "time":
|
||||
payload[channel_names[i]]=int(ch_val[i])
|
||||
if channel_names[i] in push_vars:
|
||||
if push_counter == push_count:
|
||||
sense_data=int(push_data[channel_names[i]]/(100*push_count))/10
|
||||
upload_osm(sensebox_sid[channel_names[i]],sense_data)
|
||||
push_data[channel_names[i]]=0
|
||||
else:
|
||||
push_data[channel_names[i]]=push_data[channel_names[i]]+ch_val[i]
|
||||
f1.write("\n")
|
||||
f1.close()
|
||||
json_out={"time": ch_val[channel_names.index("time")],"device": "rasolar","payload":payload}
|
||||
|
|
Loading…
Reference in New Issue