项目作者: jorticus

项目描述 :
Outback MATE python interface
高级语言: Python
项目地址: git://github.com/jorticus/pymate.git
创建时间: 2015-11-27T21:12:45Z
项目社区:https://github.com/jorticus/pymate

开源协议:GNU General Public License v2.0

下载


pyMATE

pyMATE

pyMATE is a python library that can be used to emulate an Outback MATE unit, and talk to any supported
Outback Power Inc. device such as an MX charge controller, an FX inverter, a FlexNET DC monitor, or a hub with
multiple devices attached to it.

You will need a simple adapter circuit and a TTL serial port. For more details, see jared.geek.nz/pymate

To see the library in action, check out my post on connecting it with Grafana! jared.geek.nz/grafana-outback-solar

  • outback_mate_rs232 - For use with the Mate’s RS232 port
  • uMATE - Companion Arduino library, featuring more reliable communication and better perf

MX/CC Charge Controller Interface

To set up communication with an MX charge controller:

  1. mate_bus = MateNET('COM1') # Windows
  2. mate_bus = MateNET('/dev/ttyUSB0') # Linux
  3. mate_mx = MateMXDevice(mate_bus, port=0) # 0: No hub. 1-9: Hub port
  4. mate_mx.scan() # This will raise an exception if the device isn't found

Or to automatically a hub for an attached MX:

  1. bus = MateNET('COM1', supports_spacemark=False)
  2. mate = MateMXDevice(bus, port=bus.find_device(MateNET.DEVICE_MX))
  3. # Check that an MX unit is attached and is responding
  4. mate.scan()

You can now communicate with the MX as though you are a MATE device.

Status

You can query a status with mate_mx.get_status(). This will return an MXStatusPacket with the following information:

  1. status = mate_mx.get_status()
  2. status.amp_hours # 0 - 255 Ah
  3. status.kilowatt_hours # 0.0 - 6553.5 kWh
  4. status.pv_current # 0 - 255 A
  5. status.bat_current # 0 - 255 A
  6. status.pv_voltage # 0.0 - 6553.5 V
  7. status.bat_voltage # 0.0 - 6553.5 V
  8. status.status # A status code. See MXStatusPacket.STATUS_* constants.
  9. status.errors # A 8 bit bit-field (documented in Outback's PDF)

All values are floating-point numbers with units attached. You can convert them to real floats with eg. float(status.pv_voltage) # 123.4, or display them as a human-friendly string with str(status.pv_voltage) # '123.4 V'

Log Pages

You can also query a log page (just like you can on the MATE), up to 127 days in the past: (Logpages are stored at midnight, 0 is the current day so far)

  1. logpage = mate_mx.get_logpage(-1) # Yesterday's logpage
  2. logpage.bat_max # 0.0 - 102.3 V
  3. logpage.bat_min # 0.0 - 102.3 V
  4. logpage.kilowatt_hours # 0.0 - 409.5 kWh
  5. logpage.amp_hours # 0 - 16383 Ah
  6. logpage.volts_peak # 0 - 255 Vpk
  7. logpage.amps_peak # 0.0 - 102.3 Apk
  8. logpage.absorb_time # 4095 min (minutes)
  9. logpage.float_time # 4095 min
  10. logpage.kilowatts_peak # 0.000 - 2.047 kWpk
  11. logpage.day # 0 .. -127

Properties

Additionally, you can query individual registers (just like you can on the MATE - though it’s buried quite deep in the menus somewhere)

  1. mate_mx.charger_watts
  2. mate_mx.charger_kwh
  3. mate_mx.charger_amps_dc
  4. mate_mx.bat_voltage
  5. mate_mx.panel_voltage
  6. mate_mx.status
  7. mate_mx.aux_relay_mode
  8. mate_mx.max_battery
  9. mate_mx.voc
  10. mate_mx.max_voc
  11. mate_mx.total_kwh_dc
  12. mate_mx.total_kah
  13. mate_mx.max_wattage
  14. mate_mx.setpt_absorb
  15. mate_mx.setpt_float

Note that to read each of these properties a separate message must be sent, so it will be slower than getting values from a status packet.

FX Inverter Interface

To set up communication with an FX inverter:

  1. mate_bus = MateNET('COM1') # Windows
  2. mate_bus = MateNET('/dev/ttyUSB0') # Linux
  3. mate_fx = MateDCDevice(bus, port=bus.find_device(MateNET.DEVICE_FX))
  4. mate_fx.scan()
  5. status = mate_fx.get_status()
  6. errors = mate_fx.errors
  7. warnings = mate_fx.warnings

Controls

You can control an FX unit like you can through the MATE unit:

  1. mate_fx.inverter_control = 0 # 0: Off, 1: Search, 2: On
  2. mate_fx.acin_control = 0 # 0: Drop, 1: Use
  3. mate_fx.charge_control = 0 # 0: Off, 1: Auto, 2: On
  4. mate_fx.aux_control = 0 # 0: Off, 1: Auto, 2: On
  5. mate_fx.eq_control = 0 # 0: Off, 1: Auto, 2: On

These are implemented as python properties, so you can read and write them. Writing to them affects the FX unit.

WARNING: Setting inverter_control to 0 WILL cut power to your house!

Properties

There are a bunch of interesting properties, many of which are not available from the status packet:

  1. mate_fx.disconn_status
  2. mate_fx.sell_status
  3. mate_fx.temp_battery
  4. mate_fx.temp_air
  5. mate_fx.temp_fets
  6. mate_fx.temp_capacitor
  7. mate_fx.output_voltage
  8. mate_fx.input_voltage
  9. mate_fx.inverter_current
  10. mate_fx.charger_current
  11. mate_fx.input_current
  12. mate_fx.sell_current
  13. mate_fx.battery_actual
  14. mate_fx.battery_temp_compensated
  15. mate_fx.absorb_setpoint
  16. mate_fx.absorb_time_remaining
  17. mate_fx.float_setpoint
  18. mate_fx.float_time_remaining
  19. mate_fx.refloat_setpoint
  20. mate_fx.equalize_setpoint
  21. mate_fx.equalize_time_remaining

FLEXnet DC Power Monitor Interface

To set up communication with a FLEXnet DC power monitor:

  1. mate_bus = MateNET('COM1') # Windows
  2. mate_bus = MateNET('/dev/ttyUSB0') # Linux
  3. mate_dc = MateDCDevice(bus, port=bus.find_device(MateNET.DEVICE_FLEXNETDC))
  4. mate_dc.scan()
  5. status = mate_dc.get_status()

The following information is available through get_status():

  • State of Charge (%)
  • Battery Voltage (0-80V, 0.1V resolution)
  • Current kW/Amps for Shunts A/B/C
  • Current kW/Amps for In/Out/Battery (Max +/-1000A, 10W/0.1A resolution)
  • Daily kWH/Ah for Shunts A/B/C & In/Out/Battery/Net
  • Daily minimum State of Charge
  • Days since last full charge (0.1 day resolution)

You can manually reset daily accumulated values by writing to certain registers,
but this is not yet implemented.

Example Server

For convenience, a simple server is included that captures data periodically
and uploads it to a remote server via a REST API.
The remote server then stores the received data into a database of your choice.

PJON Bridge

The default serial interface doesn’t always work well, and it’s not the most efficient,
so there is an alternative protocol you can use which pipes the data to an Arduino via PJON protocol.

To use this alternative protocol:

  1. port = MateNETPJON('COM1')
  2. bus = MateNET(port)

See this page in my uMATE project for an example bridge implementation.

MATE Protocol RE

For details on the low-level communication protocol and available registers, see doc/protocol/Protocol.md


I am open to contributions, especially if you can test it with any devices I don’t have.