Remove meaningless fixup algorithm
This commit is contained in:
parent
cb9642701e
commit
7a203753c8
18
sunspec.py
18
sunspec.py
@ -75,13 +75,13 @@ meter_events_bits = { 2: 'Power Failure',
|
|||||||
|
|
||||||
class Meter:
|
class Meter:
|
||||||
def __init__(self, regs):
|
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',
|
('ac_voltage', 5, ('average', 'a', 'b', 'c',
|
||||||
'll', 'ab', 'bc', 'ca'), 1),
|
'll', 'ab', 'bc', 'ca')),
|
||||||
('ac_real_power', 16, ('total', 'a', 'b', 'c'), 0.1),
|
('ac_real_power', 16, ('total', 'a', 'b', 'c')),
|
||||||
('ac_apparent_power', 21, ('total', 'a', 'b', 'c'), 0.1),
|
('ac_apparent_power', 21, ('total', 'a', 'b', 'c')),
|
||||||
('ac_reactive_power', 26, ('total', 'a', 'b', 'c'), 0.1),
|
('ac_reactive_power', 26, ('total', 'a', 'b', 'c')),
|
||||||
('power_factor', 31, ('average', 'a', 'b', 'c'), 1))
|
('power_factor', 31, ('average', 'a', 'b', 'c')))
|
||||||
|
|
||||||
quadrants = ['_'.join((k,q,p)) for (k, qs) in (
|
quadrants = ['_'.join((k,q,p)) for (k, qs) in (
|
||||||
('import', ('1','2')),
|
('import', ('1','2')),
|
||||||
@ -97,9 +97,9 @@ class Meter:
|
|||||||
('energy_reactive', 70, quadrants))
|
('energy_reactive', 70, quadrants))
|
||||||
|
|
||||||
|
|
||||||
for (metric, offset, labels, fix) in blocks16:
|
for (metric, offset, labels) in blocks16:
|
||||||
data = {}
|
data = {}
|
||||||
scale = regs.read_scale(offset + len(labels)) * fix
|
scale = regs.read_scale(offset + len(labels))
|
||||||
for (i, key) in enumerate(labels):
|
for (i, key) in enumerate(labels):
|
||||||
data[key] = regs.read_int16(offset + i) * scale
|
data[key] = regs.read_int16(offset + i) * scale
|
||||||
self.__dict__[metric] = data
|
self.__dict__[metric] = data
|
||||||
@ -108,7 +108,7 @@ class Meter:
|
|||||||
data = {}
|
data = {}
|
||||||
scale = regs.read_scale(offset + len(labels)*2)
|
scale = regs.read_scale(offset + len(labels)*2)
|
||||||
for (i, key) in enumerate(labels):
|
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
|
data[key] = value if value > 1 else None
|
||||||
self.__dict__[metric] = data
|
self.__dict__[metric] = data
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user