diff --git a/pi_temp.py b/pi_temp.py
index 30968df..aecc7d3 100755
--- a/pi_temp.py
+++ b/pi_temp.py
@@ -50,6 +50,7 @@ import datetime
import arrow
import json
import plotly
+import sqlite3
from plotly.graph_objs import *
app = Flask(__name__)
@@ -83,62 +84,61 @@ def history():
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.
- time_series_adjusted_tempreratures = []
- time_series_adjusted_humidities = []
- time_series_temprerature_values = []
- time_series_humidity_values = []
-
- for record in temperatures:
- local_timedate = arrow.get(record[0], "YYYY-MM-DD HH:mm").to(timezone)
- time_series_adjusted_tempreratures.append(local_timedate.format('YYYY-MM-DD HH:mm'))
- time_series_temprerature_values.append(round(record[2],2))
-
- for record in humidities:
- local_timedate = arrow.get(record[0], "YYYY-MM-DD HH:mm").to(timezone)
- time_series_adjusted_humidities.append(local_timedate.format('YYYY-MM-DD HH:mm')) #Best to pass datetime in text
- #so that Plotly respects it
- time_series_humidity_values.append(round(record[2],2))
-
-
- temp = Scatter(
- x=time_series_adjusted_tempreratures,
- y=time_series_temprerature_values,
- name='Temperature'
- )
- hum = Scatter(
- x=time_series_adjusted_humidities,
- y=time_series_humidity_values,
- name='Humidity',
- yaxis='y2'
- )
-
- data = Data([temp, hum])
-
- layout = Layout(
- title="Temperature and Humidity in Clayton's Apartment",
- xaxis=XAxis(
- type='date',
- autorange=True
- ),
- yaxis=YAxis(
- title='Fahrenheit',
- type='linear',
- autorange=True
- ),
- yaxis2=YAxis(
- title='Percent',
- type='linear',
- autorange=True,
- overlaying='y',
- side='right'
- )
-
- )
-
- fig = Figure(data=data, layout=layout)
- #plot_url = py.plot(fig, filename='lab_temp_hum')
- graphJSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
+# Create new record tables so that datetimes are adjusted back to the user browser's time zone.
+# time_series_adjusted_temperatures = []
+# time_series_adjusted_humidities = []
+# time_series_temperature_values = []
+# time_series_humidity_values = []
+#
+# for record in temperatures:
+# 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_temperature_values.append(round(record[2],2))
+#
+# for record in humidities:
+# 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
+# so that Plotly respects it
+# time_series_humidity_values.append(round(record[2],2))
+#
+#
+# temp = Scatter(
+# x=time_series_adjusted_temperatures,
+# y=time_series_temperature_values,
+# name='Temperature'
+# )
+# hum = Scatter(
+# x=time_series_adjusted_humidities,
+# y=time_series_humidity_values,
+# name='Humidity',
+# yaxis='y2'
+# )
+#
+# data = Data([temp, hum])
+#
+# layout = Layout(
+# title="Temperature and Humidity",
+# xaxis=XAxis(
+# type='date',
+# autorange=True
+# ),
+# yaxis=YAxis(
+# title='Fahrenheit',
+# type='linear',
+# autorange=True
+# ),
+# yaxis2=YAxis(
+# title='Percent',
+# type='linear',
+# autorange=True,
+# overlaying='y',
+# side='right'
+# )
+#
+# )
+#
+# fig = Figure(data=data, layout=layout)
+# graphJSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
return render_template("history.html", timezone = timezone,
temp = time_adjusted_temperatures,
@@ -149,10 +149,10 @@ def history():
query_string = request.query_string, #This query string is used
#by the Plotly link
hum_items = len(humidities),
- graphJSON=graphJSON)
+ #graphJSON=graphJSON,
+ )
def get_records():
- import sqlite3
from_date_str = request.args.get('from',time.strftime("%Y-%m-%d 00:00")) #Get the from date value from the URL
to_date_str = request.args.get('to',time.strftime("%Y-%m-%d %H:%M")) #Get the to date value from the URL
timezone = request.args.get('timezone','Etc/UTC');
diff --git a/templates/history.html b/templates/history.html
index 82497c9..2c4a1f5 100755
--- a/templates/history.html
+++ b/templates/history.html
@@ -150,7 +150,8 @@
jQuery(".timezone").val(timezone.name());
jQuery("#range_select").submit();
});
-
+
+
jQuery("#plotly").click(function(){
jQuery("#plotly_wait").text("Sending data...");
jQuery("#plotly_url").text("");
@@ -164,16 +165,15 @@
});
return false; //This is so that the click on the link does not cause the page to refresh
});
+
-
-
+
+
+
+
+
-
+
-
+
-
+
+ -->