add short names
parent
6583df9f3b
commit
1bc01f12f3
1
init.sql
1
init.sql
|
@ -7,3 +7,4 @@ create table if not exists rasolar.clients (ip varchar(16) not null unique,keyid
|
|||
create table if not exists rasolar.hourly_measures (time bigint unsigned not null, id int unsigned not null, value int unsigned not null, index(time,id));
|
||||
create table if not exists rasolar.daily_measures (time bigint unsigned not null, id int unsigned not null, value int unsigned not null, index(time,id));
|
||||
create table if not exists rasolar.last_measures (time bigint unsigned not null, id int unsigned not null, value int unsigned not null, index(time,id));
|
||||
create table if not exists rasolar.short_names (id bigint not null, short varchar(16));
|
||||
|
|
8
pyweb.py
8
pyweb.py
|
@ -225,7 +225,7 @@ def show_temperature():
|
|||
mydev[ids]=device
|
||||
myids=myids[:-1]+')'
|
||||
print(myids)
|
||||
myc.execute("select gm.time,last_measures.value/1000,ids.varname,ids.device from (select id, max(time) as time from last_measures where id in "+myids+" group by id) gm join last_measures on last_measures.id=gm.id and last_measures.time=gm.time join ids on ids.id=gm.id;")
|
||||
myc.execute("select gm.time,last_measures.value/1000,ids.varname,ids.device from (select id, max(time) as time,short_names.short from last_measures where id in "+myids+" group by id) gm join last_measures on last_measures.id=gm.id and last_measures.time=gm.time join ids on ids.id=gm.id join short_names on short_names.id=gm.id;")
|
||||
ts=myc.fetchall()
|
||||
myc.close()
|
||||
mydb.close()
|
||||
|
@ -233,8 +233,8 @@ def show_temperature():
|
|||
zs=0
|
||||
thp={"rasolar":{"temperature":0,"humidity":0,"pressure":0,"time":0},"ragps":{"temperature":0,"humidity":0,"pressure":0,"time":0},"ragarden":{"temperature":0,"humidity":0,"pressure":0,"time":0}}
|
||||
|
||||
for tims,value,varname,device in ts:
|
||||
tt[varname]=value
|
||||
for tims,value,varname,device,short in ts:
|
||||
tt[short]=value
|
||||
try:
|
||||
thp[device][varname]=value
|
||||
except:
|
||||
|
@ -246,7 +246,7 @@ def show_temperature():
|
|||
thp[device]['time']=tims
|
||||
if int(tims)>zs:
|
||||
zs=int(tims)
|
||||
return template('temperature.tpl',tempdata=thp,zeitstempel=time.strftime('%H:%M:%S %Y-%m-%d', time.localtime(zs/1000)))
|
||||
return template('temperature.tpl',tempdata=tt,zeitstempel=time.strftime('%H:%M:%S %Y-%m-%d', time.localtime(zs/1000)))
|
||||
|
||||
@app.get('/clients')
|
||||
def show_clients():
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
<p>Zeit: {{zeitstempel}}</p>
|
||||
<table>
|
||||
<tr><th>Ort</th> <th>Temperatur</th> <th>Luftfeuchte </th> <th>Luftdruck </th><th>lux</th><th>UV </th></tr>
|
||||
<tr><th>CarPort</th> <th>{{tempdata['rasolar']['temperature']}}</th> <th>{{tempdata['rasolar']['humidity']}} </th> <th>{{tempdata['rasolar']['pressure']}} </th><th></th></tr>
|
||||
<tr><th>Dach</th> <th>{{tempdata['ragps']['temperature']}}</th> <th>{{tempdata['ragps']['humidity']}} </th> <th>{{tempdata['ragps']['pressure']}} </th><th>{{tempdata['ragps']['lux']}}</th><th>{{tempdata['ragps']['uv']}}</th></tr>
|
||||
<tr><th>Garten</th> <th>{{tempdata['ragarden']['temperature']}}</th> <th>{{tempdata['ragarden']['humidity']}} </th> <th>{{tempdata['ragarden']['pressure']}} </th><th></th><th></th></tr>
|
||||
<tr><th>CarPort</th> <th>{{tempdata['temp_carport']}}</th> <th>{{tempdata['hum_carport']}} </th> <th>{{tempdata['press_carport']}} </th><th></th></tr>
|
||||
<tr><th>Dach</th> <th>{{tempdata['temp_dach']}}</th> <th>{{tempdata['hum_dach']}} </th> <th>{{tempdata['press_dach']}} </th><th>{{tempdata['lux_dach']}}</th><th>{{tempdata['uv_dach']}}</th></tr>
|
||||
<tr><th>Garten</th> <th>{{tempdata['temp_garten']}}</th> <th>{{tempdata['hum_garten']}} </th> <th>{{tempdata['press_garten']}} </th><th></th><th></th></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue