Advertisement
Guest User

myscript.py

a guest
Feb 21st, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. import pv
  2. pv.debug()
  3. pv.debug_color()
  4. import serial
  5. port = serial.Serial('/dev/ttyUSB0')
  6. port.open()
  7. from pv import cms
  8. inv = cms.Inverter(port)
  9. inv.reset()                  # Reset all communications on the serial connection
  10. sn = inv.discover()          # Look for connected devices
  11. if sn is None:
  12.         print "Inverter is not connected."
  13.         sys.exit(1)
  14. ok = inv.register(sn)      # Associates the inverter and assigns default address
  15. if not ok:
  16.         print "Inverter registration failed."
  17.         sys.exit(1)
  18.         print inv.version()
  19.         param_layout = inv.param_layout()
  20.         parameters = inv.parameters(param_layout)
  21. for field in parameters:
  22.         print "%-10s: %s" % field
  23.  
  24. status_layout = inv.status_layout()
  25. status = inv.status(status_layout)
  26. for field in status:
  27.         print "%-10s: %s" % field
  28.         from pv import pvoutput
  29. api_key = 'xxx'
  30. system_id = xxx
  31. conn = pvoutput.Connection(api_key, system_id)
  32. import time
  33. status = dict(status)
  34. conn.add_status(
  35.         time.strftime('%Y%m%d'),
  36.         time.strftime('%H:%M'),
  37.         energy_exp=status['E-Total'],
  38.         power_exp=status['Pac'],
  39.         cumulative=True)
  40. print conn.get_status()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement