diff --git a/sunspec.py b/sunspec.py index 994cfca..152a165 100644 --- a/sunspec.py +++ b/sunspec.py @@ -75,13 +75,13 @@ meter_events_bits = { 2: 'Power Failure', class Meter: def __init__(self, regs): - blocks16 = (('ac_current', 0, ('total', 'a', 'b', 'c'), 0.1), + blocks16 = (('ac_current', 0, ('total', 'a', 'b', 'c')), ('ac_voltage', 5, ('average', 'a', 'b', 'c', - 'll', 'ab', 'bc', 'ca'), 1), - ('ac_real_power', 16, ('total', 'a', 'b', 'c'), 0.1), - ('ac_apparent_power', 21, ('total', 'a', 'b', 'c'), 0.1), - ('ac_reactive_power', 26, ('total', 'a', 'b', 'c'), 0.1), - ('power_factor', 31, ('average', 'a', 'b', 'c'), 1)) + 'll', 'ab', 'bc', 'ca')), + ('ac_real_power', 16, ('total', 'a', 'b', 'c')), + ('ac_apparent_power', 21, ('total', 'a', 'b', 'c')), + ('ac_reactive_power', 26, ('total', 'a', 'b', 'c')), + ('power_factor', 31, ('average', 'a', 'b', 'c'))) quadrants = ['_'.join((k,q,p)) for (k, qs) in ( ('import', ('1','2')), @@ -97,9 +97,9 @@ class Meter: ('energy_reactive', 70, quadrants)) - for (metric, offset, labels, fix) in blocks16: + for (metric, offset, labels) in blocks16: data = {} - scale = regs.read_scale(offset + len(labels)) * fix + scale = regs.read_scale(offset + len(labels)) for (i, key) in enumerate(labels): data[key] = regs.read_int16(offset + i) * scale self.__dict__[metric] = data @@ -108,7 +108,7 @@ class Meter: data = {} scale = regs.read_scale(offset + len(labels)*2) for (i, key) in enumerate(labels): - value = regs.read_uint32(offset + 2*i) * scale / 10 + value = regs.read_uint32(offset + 2*i) * scale data[key] = value if value > 1 else None self.__dict__[metric] = data