Skip to content

Commit 4f1447b

Browse files
authored
Merge pull request #3 from scline/master
Allow password-less InfluxDB and correct sample config variable
2 parents 42ec6ff + 4d22455 commit 4f1447b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/vuegraf.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
with open(configFilename) as configFile:
1818
config = json.load(configFile)
1919

20-
influx = InfluxDBClient(config['influxDb']['host'], config['influxDb']['port'], config['influxDb']['user'], config['influxDb']['pass'], config['influxDb']['database'])
20+
# if 'user'entry exsists within influxdb variable use auth to create db, if none are given dont use any auth
21+
if 'user' in config['influxDb']:
22+
influx = InfluxDBClient(host=config['influxDb']['host'], port=config['influxDb']['port'], username=config['influxDb']['user'], password=config['influxDb']['pass'], database=config['influxDb']['database'])
23+
else:
24+
influx = InfluxDBClient(host=config['influxDb']['host'], port=config['influxDb']['port'], database=config['influxDb']['database'])
25+
2126
influx.create_database(config['influxDb']['database'])
2227

2328
running = True
@@ -108,6 +113,7 @@ def lookupChannelName(account, chan):
108113
account['end'] = tmpEndingTime
109114

110115
start = account['end'] - datetime.timedelta(seconds=INTERVAL_SECS)
116+
111117
result = influx.query('select last(usage), time from energy_usage where account_name = \'{}\''.format(account['name']))
112118
if len(result) > 0:
113119
timeStr = next(result.get_points())['time'][:26] + 'Z'

vuegraf.json.sample

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"user": "root",
66
"pass": "root",
77
"database": "vue",
8-
"reset": "false"
8+
"reset": false
99
},
1010
"accounts": [
1111
{
@@ -42,4 +42,4 @@
4242
]
4343
}
4444
]
45-
}
45+
}

0 commit comments

Comments
 (0)