diff --git a/modules/core/core.py b/modules/core/core.py index 368f412..e70d04c 100644 --- a/modules/core/core.py +++ b/modules/core/core.py @@ -157,7 +157,8 @@ class SensorAPI(object): dict(name="cbpi." + sensor_name, datapoints=[ [int(round(time.time() * 1000)), value] ], tags={ - "cbpi": prefix + "cbpi": prefix, + "brew": self.cache["active_brew"] }) ] diff --git a/modules/steps/__init__.py b/modules/steps/__init__.py index 05d65fc..3b2b75f 100755 --- a/modules/steps/__init__.py +++ b/modules/steps/__init__.py @@ -1,4 +1,5 @@ import time +import datetime from flask import json, request from flask_classy import route @@ -142,9 +143,14 @@ class StepView(BaseView): # set step instance to ache cbpi.cache["active_step"] = instance - @route('/next', methods=['POST']) @route('/start', methods=['POST']) def start(self): + cbpi.cache["active_brew"] = cbpi.cache["config"]["brew_name"].__dict__["value"] + \ + "_" + datetime.datetime.now().strftime('%y-%m-%dT%H:%M') + return self.next() + + @route('/next', methods=['POST']) + def next(self): active = Step.get_by_state("A") inactive = Step.get_by_state('I') @@ -163,6 +169,7 @@ class StepView(BaseView): else: cbpi.log_action("Brewing Finished") cbpi.notify("Brewing Finished", "You are done!", timeout=None) + cbpi.cache["active_brew"] = "none" cbpi.emit("UPDATE_ALL_STEPS", Step.get_all()) return ('', 204) diff --git a/update/4_kairosdb_config.sql b/update/4_kairosdb_config.sql index 35e0af8..3415309 100644 --- a/update/4_kairosdb_config.sql +++ b/update/4_kairosdb_config.sql @@ -1,2 +1,2 @@ INSERT OR IGNORE INTO config VALUES ('kairos_db', 'NO', 'select', 'Use timeseries database KairosDB for storing sensor values. For now you have to install KairosDB by yourself.', '["YES","NO"]' ); -INSERT OR IGNORE INTO config VALUES ('kairos_db_port', 5001, 'number', 'Port for KairosDB. We assume the DB is running on your PI, so IP-Address is 127.0.0.1.', NULL ); \ No newline at end of file +INSERT OR IGNORE INTO config VALUES ('kairos_db_port', 8080, 'number', 'Port for KairosDB. We assume the DB is running on your PI, so IP-Address is 127.0.0.1.', NULL ); \ No newline at end of file