Calculate how much the furnace is running #30

Merged
mattbk merged 3 commits from threshold into master 2017-11-24 22:54:26 -06:00
2 changed files with 120 additions and 99 deletions
Showing only changes of commit fc17ab2a86 - Show all commits

View File

@ -122,10 +122,29 @@ def history():
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)
x = time_series_temperature_values
result = longest_streak(x)
return render_template("history.html", timezone = timezone, return render_template("history.html", timezone = timezone,
graphJSON = graphJSON, graphJSON = graphJSON,
result = result,
) )
def longest_streak(grades):
if len(grades) < 2:
return len(grades)
else:
start, streaks = -1, []
for idx, (x, y) in enumerate(zip(grades, grades[1:])):
if x > y:
streaks.append(idx - start)
start = idx
else:
streaks.append(idx - start + 1)
long_streaks = [x for x in streaks if x > 3]
return long_streaks
def get_records(): def get_records():
from_date_str = request.args.get('from',time.strftime("%Y-%m-%d 00:00")) #Get the from date value from the URL 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 to_date_str = request.args.get('to',time.strftime("%Y-%m-%d %H:%M")) #Get the to date value from the URL

View File

@ -79,6 +79,8 @@
</div> </div>
<div class='row' id='plotly-plot'></div> <div class='row' id='plotly-plot'></div>
{{ result }}
</body> </body>
<footer> <footer>