Skip to content

Commit

Permalink
create a simpler on/off config for detailed data
Browse files Browse the repository at this point in the history
  • Loading branch information
jertel committed Jan 2, 2023
1 parent 4744a0d commit 001df3a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ To provide more user-friendly names of each Vue device and branch circuit, the f

### Per-second Data Details

By default, Vuegraf will poll every minute to collect the energy usage value over the past 60 seconds. This results in a single value being capture per minute, or 60 values per hour. If you also would like to see per-second values, you can enable the detailed collection, which is polled once per hour, and backfilled over the previous 3600 seconds. This API call is very expensive on the Emporia servers, so it should not be polled more frequently than once per hour. To enable this detailed data, add (or update) the top-level `detailedIntervalSecs` configuration value with a value of `3600`.
By default, Vuegraf will poll every minute to collect the energy usage value over the past 60 seconds. This results in a single value being capture per minute per channel, or 60 values per hour per channel. If you also would like to see per-second values, you can enable the detailed collection, which is polled once per hour, and backfilled over the previous 3600 seconds. This API call is very expensive on the Emporia servers, so it should not be polled more frequently than once per hour. To enable this detailed data, add (or update) the top-level `detailedDataEnabled` configuration value with a value of `true`.

```
detailedIntervalSecs: 3600
detailedDataEnabled: true
```

## Vue Utility Connect Energy Monitor
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
base_dir = os.path.dirname(__file__)
setup(
name='vuegraf',
version='1.4.0',
version='1.5.0',
author='Jason Ertel',
url='https://github.com/jertel/vuegraf',
description='Populate metrics from your Emporia Vue energy monitoring devices into an InfluxDB',
Expand Down
10 changes: 6 additions & 4 deletions src/vuegraf/vuegraf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def extractDataPoints(device, usageDataPoints, historyStartTime=None, historyEnd
if chanNum in excludedDetailChannelNumbers:
continue

if detailedEnabled:
if collectDetails:
usage, usage_start_time = account['vue'].get_chart_usage(chan, detailedStartTime, stopTime, scale=Scale.SECOND.value, unit=Unit.KWH.value)
index = 0
for kwhUsage in usage:
Expand Down Expand Up @@ -229,14 +229,16 @@ def extractDataPoints(device, usageDataPoints, historyStartTime=None, historyEnd
pauseEvent = Event()

intervalSecs=getConfigValue("updateIntervalSecs", 60)
detailedIntervalSecs=getConfigValue("detailedIntervalSecs", 0)
detailedIntervalSecs=getConfigValue("detailedIntervalSecs", 3600)
detailedDataEnabled=getConfigValue("detailedDataEnabled", False);
info('Settings -> updateIntervalSecs: {}, detailedEnabled: {}, detailedIntervalSecs: {}'.format(intervalSecs, detailedIntervalSecs, detailedDataEnabled))
lagSecs=getConfigValue("lagSecs", 5)
detailedStartTime = startupTime

while running:
now = datetime.datetime.utcnow()
stopTime = now - datetime.timedelta(seconds=lagSecs)
detailedEnabled = detailedIntervalSecs > 0 and (stopTime - detailedStartTime).total_seconds() >= detailedIntervalSecs
collectDetails = detailedDataEnabled and detailedIntervalSecs > 0 and (stopTime - detailedStartTime).total_seconds() >= detailedIntervalSecs

for account in config["accounts"]:
if 'vue' not in account:
Expand Down Expand Up @@ -285,7 +287,7 @@ def extractDataPoints(device, usageDataPoints, historyStartTime=None, historyEnd
error('Failed to record new usage data: {}'.format(sys.exc_info()))
traceback.print_exc()

if detailedEnabled:
if collectDetails:
detailedStartTime = stopTime + datetime.timedelta(seconds=1)

pauseEvent.wait(intervalSecs)
Expand Down
1 change: 0 additions & 1 deletion vuegraf.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"ssl_enable": false,
"ssl_verify": true
},
"detailedIntervalSecs": 0,
"updateIntervalSecs": 60,
"accounts": [
{
Expand Down

0 comments on commit 001df3a

Please sign in to comment.