Aaaaaaaah.
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
pi_temp.db
|
BIN
pi_temp.db
BIN
pi_temp.db
Binary file not shown.
108
pi_temp.py
108
pi_temp.py
@ -85,60 +85,60 @@ def history():
|
|||||||
print "rendering history.html with: %s, %s, %s" % (timezone, from_date_str, to_date_str)
|
print "rendering history.html with: %s, %s, %s" % (timezone, from_date_str, to_date_str)
|
||||||
|
|
||||||
# Create new record tables so that datetimes are adjusted back to the user browser's time zone.
|
# Create new record tables so that datetimes are adjusted back to the user browser's time zone.
|
||||||
# time_series_adjusted_temperatures = []
|
time_series_adjusted_temperatures = []
|
||||||
# time_series_adjusted_humidities = []
|
time_series_adjusted_humidities = []
|
||||||
# time_series_temperature_values = []
|
time_series_temperature_values = []
|
||||||
# time_series_humidity_values = []
|
time_series_humidity_values = []
|
||||||
#
|
|
||||||
# for record in temperatures:
|
for record in temperatures:
|
||||||
# local_timedate_series = arrow.get(record[0], "YYYY-MM-DD HH:mm").to(timezone)
|
local_timedate_series = arrow.get(record[0], "YYYY-MM-DD HH:mm").to(timezone)
|
||||||
# time_series_adjusted_temperatures.append(local_timedate_series.format('YYYY-MM-DD HH:mm'))
|
time_series_adjusted_temperatures.append(local_timedate_series.format('YYYY-MM-DD HH:mm'))
|
||||||
# time_series_temperature_values.append(round(record[2],2))
|
time_series_temperature_values.append(round(record[2],2))
|
||||||
#
|
|
||||||
# for record in humidities:
|
for record in humidities:
|
||||||
# local_timedate_series = arrow.get(record[0], "YYYY-MM-DD HH:mm").to(timezone)
|
local_timedate_series = arrow.get(record[0], "YYYY-MM-DD HH:mm").to(timezone)
|
||||||
# time_series_adjusted_humidities.append(local_timedate_series.format('YYYY-MM-DD HH:mm')) #Best to pass datetime in text
|
time_series_adjusted_humidities.append(local_timedate_series.format('YYYY-MM-DD HH:mm')) #Best to pass datetime in text
|
||||||
#so that Plotly respects it
|
#so that Plotly respects it
|
||||||
# time_series_humidity_values.append(round(record[2],2))
|
time_series_humidity_values.append(round(record[2],2))
|
||||||
#
|
|
||||||
#
|
|
||||||
# temp = Scatter(
|
temp = Scatter(
|
||||||
# x=time_series_adjusted_temperatures,
|
x=time_series_adjusted_temperatures,
|
||||||
# y=time_series_temperature_values,
|
y=time_series_temperature_values,
|
||||||
# name='Temperature'
|
name='Temperature'
|
||||||
# )
|
)
|
||||||
# hum = Scatter(
|
hum = Scatter(
|
||||||
# x=time_series_adjusted_humidities,
|
x=time_series_adjusted_humidities,
|
||||||
# y=time_series_humidity_values,
|
y=time_series_humidity_values,
|
||||||
# name='Humidity',
|
name='Humidity',
|
||||||
# yaxis='y2'
|
yaxis='y2'
|
||||||
# )
|
)
|
||||||
#
|
|
||||||
# data = Data([temp, hum])
|
data = Data([temp, hum])
|
||||||
#
|
|
||||||
# layout = Layout(
|
layout = Layout(
|
||||||
# title="Temperature and Humidity",
|
title="Temperature and Humidity",
|
||||||
# xaxis=XAxis(
|
xaxis=XAxis(
|
||||||
# type='date',
|
type='date',
|
||||||
# autorange=True
|
autorange=True
|
||||||
# ),
|
),
|
||||||
# yaxis=YAxis(
|
yaxis=YAxis(
|
||||||
# title='Fahrenheit',
|
title='Fahrenheit',
|
||||||
# type='linear',
|
type='linear',
|
||||||
# autorange=True
|
autorange=True
|
||||||
# ),
|
),
|
||||||
# yaxis2=YAxis(
|
yaxis2=YAxis(
|
||||||
# title='Percent',
|
title='Percent',
|
||||||
# type='linear',
|
type='linear',
|
||||||
# autorange=True,
|
autorange=True,
|
||||||
# overlaying='y',
|
overlaying='y',
|
||||||
# side='right'
|
side='right'
|
||||||
# )
|
)
|
||||||
#
|
|
||||||
# )
|
)
|
||||||
#
|
|
||||||
# fig = Figure(data=data, layout=layout)
|
fig = Figure(data=data, layout=layout)
|
||||||
# graphJSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
|
graphJSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
|
||||||
|
|
||||||
return render_template("history.html", timezone = timezone,
|
return render_template("history.html", timezone = timezone,
|
||||||
temp = time_adjusted_temperatures,
|
temp = time_adjusted_temperatures,
|
||||||
@ -149,7 +149,7 @@ def history():
|
|||||||
query_string = request.query_string, #This query string is used
|
query_string = request.query_string, #This query string is used
|
||||||
#by the Plotly link
|
#by the Plotly link
|
||||||
hum_items = len(humidities),
|
hum_items = len(humidities),
|
||||||
#graphJSON=graphJSON,
|
graphJSON=graphJSON,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_records():
|
def get_records():
|
||||||
|
@ -39,7 +39,7 @@ import sys
|
|||||||
import Adafruit_DHT
|
import Adafruit_DHT
|
||||||
|
|
||||||
def log_values(sensor_id, temp, hum):
|
def log_values(sensor_id, temp, hum):
|
||||||
conn=sqlite3.connect('/home/pi/Documents/pi-temp/pi-temp.db') #It is important to provide an
|
conn=sqlite3.connect('/home/pi/Documents/pi-temp/pi_temp.db') #It is important to provide an
|
||||||
#absolute path to the database
|
#absolute path to the database
|
||||||
#file, otherwise Cron won't be
|
#file, otherwise Cron won't be
|
||||||
#able to find it!
|
#able to find it!
|
||||||
|
@ -229,8 +229,6 @@
|
|||||||
chart.draw(data, options);
|
chart.draw(data, options);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
|
||||||
<div id='plotly-plot'></div>
|
<div id='plotly-plot'></div>
|
||||||
|
|
||||||
{{ graphJSON }}
|
{{ graphJSON }}
|
||||||
@ -248,6 +246,5 @@
|
|||||||
Plotly.plot('plotly-plot', graph.data, graph.layout);
|
Plotly.plot('plotly-plot', graph.data, graph.layout);
|
||||||
</script>
|
</script>
|
||||||
</footer>
|
</footer>
|
||||||
-->
|
|
||||||
|
|
||||||
</html>
|
-</html>
|
Reference in New Issue
Block a user