Mercurial > code > home > repos > homeauto
diff lib/export_to_influxdb.py @ 1153:e4f49cd9dda3
add :pointsAtLeastEvery control
Ignore-this: 9d0236b56b2a7592211ca68b87b4a5d1
darcs-hash:76e4d358cb6b039351c9b6f8e3bb825aaaefcc57
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 15 Apr 2018 04:41:00 -0700 |
parents | eb36b30f53b9 |
children | b50a13ef20ba |
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