Whitespace cleanups; rename InfluxDB field from "gauge" to "value"
... this abandons Prometheus "compatibility" for a better fit with InfluxDB naming.
This commit is contained in:
parent
4e68925d34
commit
10bf0b4f1e
23
bms.py
23
bms.py
@ -225,11 +225,11 @@ def parse_03_response(response):
|
||||
|
||||
current = bytes_to_digits(response[6], response[7])
|
||||
current = convert_to_signed(current) * 0.01
|
||||
data["bms_current_amps"] = dict()
|
||||
data["bms_current_amps"]['help'] = "Current"
|
||||
data["bms_current_amps"]['raw_value'] = current
|
||||
data["bms_current_amps"]['value'] = "{:.2f}".format(current)
|
||||
data["bms_current_amps"]['units'] = "A"
|
||||
data['bms_current_amps'] = dict()
|
||||
data['bms_current_amps']['help'] = "Current"
|
||||
data['bms_current_amps']['raw_value'] = current
|
||||
data['bms_current_amps']['value'] = "{:.2f}".format(current)
|
||||
data['bms_current_amps']['units'] = "A"
|
||||
if debug > 1:
|
||||
print("Current: {:.2f}A".format(current))
|
||||
|
||||
@ -689,15 +689,15 @@ def influxdb_create_snapshot(data):
|
||||
helpmsg = ''
|
||||
units = ''
|
||||
now = datetime.datetime.now(datetime.timezone.utc).isoformat()
|
||||
''' Note that the fieldname is set to "gauge" in order to retain
|
||||
compatibility with data imported from Prometheus (and it's
|
||||
as good a name as any). '''
|
||||
for kind, contains in data.items():
|
||||
helpmsg = None
|
||||
if contains.get('help'):
|
||||
helpmsg = contains.get('help')
|
||||
units = None
|
||||
if contains.get('units'):
|
||||
units = contains.get('units')
|
||||
# Simple values
|
||||
value = None
|
||||
if contains.get('raw_value') is not None:
|
||||
value = contains.get('raw_value')
|
||||
if debug > 2:
|
||||
@ -705,10 +705,11 @@ def influxdb_create_snapshot(data):
|
||||
point = Point(kind) \
|
||||
.tag("units", units) \
|
||||
.tag("help", helpmsg) \
|
||||
.field("gauge", value) \
|
||||
.field("value", value) \
|
||||
.time(now)
|
||||
points.append(point)
|
||||
# Doesn't have a value, but multiple values, each with a label:
|
||||
label = None
|
||||
if contains.get('raw_values') is not None and isinstance(contains.get('raw_values'), dict):
|
||||
label = contains.get('label')
|
||||
for idx, label_value in contains.get('raw_values').items():
|
||||
@ -718,7 +719,7 @@ def influxdb_create_snapshot(data):
|
||||
.tag(label, idx) \
|
||||
.tag("units", units) \
|
||||
.tag("help", helpmsg) \
|
||||
.field("gauge", label_value) \
|
||||
.field("value", label_value) \
|
||||
.time(now)
|
||||
points.append(point)
|
||||
# Information (like a manufacturing date or a serial number)
|
||||
@ -729,7 +730,7 @@ def influxdb_create_snapshot(data):
|
||||
point = Point(kind) \
|
||||
.tag("units", units) \
|
||||
.tag("help", helpmsg) \
|
||||
.field("gauge", value) \
|
||||
.field("value", value) \
|
||||
.time(now)
|
||||
points.append(point)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user