Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pv
- pv.debug()
- pv.debug_color()
- import serial
- port = serial.Serial('/dev/ttyUSB0')
- port.open()
- from pv import cms
- inv = cms.Inverter(port)
- inv.reset() # Reset all communications on the serial connection
- sn = inv.discover() # Look for connected devices
- if sn is None:
- print "Inverter is not connected."
- sys.exit(1)
- ok = inv.register(sn) # Associates the inverter and assigns default address
- if not ok:
- print "Inverter registration failed."
- sys.exit(1)
- print inv.version()
- param_layout = inv.param_layout()
- parameters = inv.parameters(param_layout)
- for field in parameters:
- print "%-10s: %s" % field
- status_layout = inv.status_layout()
- status = inv.status(status_layout)
- for field in status:
- print "%-10s: %s" % field
- from pv import pvoutput
- api_key = 'xxx'
- system_id = xxx
- conn = pvoutput.Connection(api_key, system_id)
- import time
- status = dict(status)
- conn.add_status(
- time.strftime('%Y%m%d'),
- time.strftime('%H:%M'),
- energy_exp=status['E-Total'],
- power_exp=status['Pac'],
- cumulative=True)
- print conn.get_status()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement