Преглед изворни кода

Added writing to Time Series Database KairosDB

pull/194/head
Johannes пре 7 година
родитељ
комит
ac328b843d
3 измењених фајлова са 11 додато и 3 уклоњено
  1. +2
    -1
      modules/core/core.py
  2. +8
    -1
      modules/steps/__init__.py
  3. +1
    -1
      update/4_kairosdb_config.sql

+ 2
- 1
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"]
})
]



+ 8
- 1
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)


+ 1
- 1
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 );
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 );

Loading…
Откажи
Сачувај