Mercurial > code > home > repos > homeauto
changeset 348:bf2174646809
add :pointsAtLeastEvery control
Ignore-this: 9d0236b56b2a7592211ca68b87b4a5d1
author | drewp@bigasterisk.com |
---|---|
date | Sun, 15 Apr 2018 04:41:00 -0700 |
parents | 97f5cbcac00b |
children | 88bd46f4e28c |
files | lib/export_to_influxdb.py service/piNode/config/kitchen.n3 |
diffstat | 2 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/export_to_influxdb.py Sun Apr 15 04:18:11 2018 -0700 +++ b/lib/export_to_influxdb.py Sun Apr 15 04:41:00 2018 -0700 @@ -31,9 +31,12 @@ tags[k] = graph.value(t, ROOM['value']).toPython() value = self.influxValue(stmt[2]) + pale = 3600 + if graph.value(meas, ROOM['pointsAtLeastEvery'], default=None): + pale = graph.value(meas, ROOM['pointsAtLeastEvery']).toPython() if not self.shouldSendNewPoint(now, stmt[0], measurementName, - tags, value): + tags, value, pointsAtLeastEvery=pale): continue points.append({ @@ -57,11 +60,11 @@ raise NotImplementedError('value=%r' % value) return value - def shouldSendNewPoint(self, now, subj, measurementName, tags, value): + def shouldSendNewPoint(self, now, subj, measurementName, tags, value, pointsAtLeastEvery): key = (subj, measurementName, tuple(sorted(tags.items()))) if key in self.lastSent: lastTime, lastValue = self.lastSent[key] - if lastValue == value and lastTime > now - 3600: + if lastValue == value and lastTime > now - pointsAtLeastEvery: log.debug('skip influx point %r', key) return False
--- a/service/piNode/config/kitchen.n3 Sun Apr 15 04:18:11 2018 -0700 +++ b/service/piNode/config/kitchen.n3 Sun Apr 15 04:41:00 2018 -0700 @@ -28,6 +28,7 @@ :influxMeasurement [ :measurement "temperatureF"; :predicate :temperatureF; + :pointsAtLeastEvery 10; :tag [:key "host"; :value "kitchen"], [:key "location"; :value "kitchenCounter"]], [ :measurement "humidity"; :predicate :humidity;