Compare commits
2 Commits
93f77776e0
...
7a203753c8
Author | SHA1 | Date | |
---|---|---|---|
7a203753c8 | |||
cb9642701e |
@ -11,7 +11,7 @@ metric_data = {
|
||||
"dc_power_watts": ["gauge", "Input bus power"],
|
||||
"energy_watthours_total": ["counter", "Power meter total"],
|
||||
"temperature_celsius": ["gauge", "Temperature"],
|
||||
"inverter_status": ["gauge", "Inverter state (0=off, 3=producing, 5=fault)"],
|
||||
"inverter_status": ["gauge", "Inverter state (1=off, 2=sleep, 4=producing, 7=fault)"],
|
||||
"inverter_status_vendor": ["gauge", "Inverter vendor-specific fault code"],
|
||||
"ac_current_amps": ["gauge", "Output bus current"],
|
||||
"ac_voltage_volts": ["gauge", "Output bus voltage"],
|
||||
@ -29,8 +29,8 @@ def export(d, m):
|
||||
yield ('ac_current_amps', {'phase': 'b', 'meter': 'production'}, d.ac_current_b)
|
||||
yield ('ac_current_amps', {'phase': 'c', 'meter': 'production'}, d.ac_current_c)
|
||||
yield ('ac_power_watts', {'power': 'active', 'meter': 'production'}, d.ac_power)
|
||||
yield ('ac_power_watts', {'power': 'reactive', 'meter': 'production'}, d.ac_apparent_power)
|
||||
yield ('ac_power_watts', {'power': 'apparent', 'meter': 'production'}, d.ac_reactive_power)
|
||||
yield ('ac_power_watts', {'power': 'reactive', 'meter': 'production'}, d.ac_reactive_power)
|
||||
yield ('ac_power_watts', {'power': 'apparent', 'meter': 'production'}, d.ac_apparent_power)
|
||||
yield ('energy_watthours_total', {'meter': 'production'}, d.ac_energy)
|
||||
yield ('ac_voltage_volts', {'phase': 'ab', 'meter': 'production'}, d.ac_voltage_ab)
|
||||
yield ('ac_voltage_volts', {'phase': 'bc', 'meter': 'production'}, d.ac_voltage_bc)
|
||||
@ -86,7 +86,7 @@ def main():
|
||||
|
||||
|
||||
prom.run(collect, metric_data, 'SolarEdge Modbus/TCP Exporter\n',
|
||||
host=args.bind, port=args.bind_port, debug=args.debug)
|
||||
host=args.listen, port=args.listen_port, debug=args.debug)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
18
sunspec.py
18
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user