项目作者: chinezbrun

项目描述 :
Integrates OutbackMate3 with HA
高级语言: Python
项目地址: git://github.com/chinezbrun/mate3_homeassistant.git
创建时间: 2020-09-26T06:02:32Z
项目社区:https://github.com/chinezbrun/mate3_homeassistant

开源协议:

下载


OutBackPower Mate3 integration with Home Assistant

Home Assistant
card
card

How Does This Software Work?

This integration is based on ReadMateStatusModBus.py (RMS) for reading MATE3 and ChangeMateStatusModBus.py (CMS) for writing data.

  • RMS creates a JSON file with almost all useful parameters extracted from Mate3 and pushes MQTT data for selected parameters. More functionalities of RMS can be configured in the config file (config.cfg).
  • Home Assistant needs to be configured to receive MQTT or decode the JSON file.
  • An MQTT broker must be installed (MQTT documentation is outside the scope of this project).
  • Running CMS will write a specific parameter to MATE3. More details can be found here.

ReadMateStatusModBus.py

  • Queries MATE3/MATE3S, retrieves data, formats it, registers it in the MariaDB database (optional - more info here), pushes MQTT data, and returns a JSON file.
  • The ReadMateStatusModBus.py script should run at a set interval. A task should be created for this (Windows or Linux).
  • config.cfg is the configuration file for the script and should be set up based on your needs.

ReadMateStatusModBus.sh (Optional)

This is an example Linux script that can be used to start ReadMateStatusModBus.py. The script should run at the desired update frequency (e.g., every minute). Refer to your OS or distribution’s documentation for setting up daemons or scheduled tasks.

ChangeMateStatusModBus.py

  • ChangeMateStatusModBus.py can write ModBus data to MATE3. A few parameters can be changed.
  • The script accepts arguments to indicate the parameters to be changed. It can also change multiple parameters during a single run.
  • More details can be found here.
  • Integration in Home Assistant can be achieved using shell commands. Examples are below and in the documentation folder here.

Home Assistant Configuration

A new folder named data should be created in the www folder located in Home Assistant (e.g., \home-assistant\www\data). This folder is where the JSON file will be saved by RMS.

Integration Variants

  1. MQTT - Predefined Parameters with Individual Topics:

    • Use MQTT Explorer to view the full list of available topics.
  2. MQTT - Access to All Parameters:

    • A single common topic, outback/mate, provides a payload containing the JSON with all data (same as the JSON file saved by the script).
  3. JSON File Decoding:

    • Use the file platform integration in Home Assistant to decode the JSON file saved in the Home Assistant folder (/config/www/data/status.json).

Sensor Configuration in configuration.yaml

Variant 1: MQTT - Predefined Sensors

Add the following sensors in configuration.yaml:

  1. mqtt:
  2. sensor:
  3. - name: outback_ac_input
  4. state_topic: "outback/inverters/1/ac_input"
  5. unit_of_measurement: "V"
  6. state_class: "measurement"
  7. - name: outback_ac_output
  8. state_topic: "outback/inverters/1/ac_output"
  9. unit_of_measurement: "V"
  10. state_class: "measurement"
  11. - name: outback_grid_status
  12. state_topic: "outback/inverters/1/ac_use"
  13. - name: outback_grid_input_mode
  14. state_topic: "outback/inverters/1/grid_input_mode"
  15. - name: outback_charger_mode
  16. state_topic: "outback/inverters/1/charger_mode"
  17. - name: outback_ops_mode
  18. state_topic: "outback/inverters/1/operating_modes"
  19. - name: outback_charge_mode
  20. state_topic: "outback/chargers/1/charge_mode"
  21. - name: outback_soc
  22. state_topic: "outback/fndc/state_of_charge"
  23. unit_of_measurement: "%"
  24. state_class: "measurement"
  25. - name: outback_bat_voltage
  26. state_topic: "outback/fndc/battery_voltage"
  27. value_template: "{{value | round(1) }}"
  28. unit_of_measurement: "V"
  29. state_class: "measurement"
  30. - name: outback_bat_temp
  31. state_topic: "outback/fndc/battery_temperature"
  32. unit_of_measurement: "°C"
  33. state_class: "measurement"
  34. - name: outback_pv_power
  35. state_topic: "outback/summary/cc_total_watts"
  36. unit_of_measurement: "W"
  37. state_class: "measurement"
  38. - name: outback_input_amp
  39. state_topic: "outback/fndc/shunt_a_current"
  40. unit_of_measurement: "A"
  41. state_class: "measurement"
  42. - name: outback_used_amp
  43. state_topic: "outback/fndc/shunt_b_current"
  44. unit_of_measurement: "A"
  45. state_class: "measurement"
  46. - name: outback_divert_amp
  47. state_topic: "outback/fndc/shunt_c_current"
  48. unit_of_measurement: "A"
  49. state_class: "measurement"
  50. - name: outback_since_charge_met
  51. state_topic: "home-assistant/outback/fndc_since_charge_met"
  52. unit_of_measurement: "days"
  53. value_template: '{{value | round(2)}}'
  54. - name: outback_charge_met
  55. state_topic: "outback/fndc/charge_params_met"
  56. - name: outback_today_net_input_kwh
  57. state_topic: "outback/fndc/todays_net_input_kWh"
  58. state_class: 'total_increasing'
  59. device_class: energy
  60. unit_of_measurement: kWh
  61. value_template: '{{value | round(2)}}'
  62. - name: outback_today_net_output_kwh
  63. state_topic: "outback/fndc/todays_net_output_kWh"
  64. state_class: 'total_increasing'
  65. device_class: energy
  66. unit_of_measurement: kWh
  67. value_template: '{{value | round(2)}}'
  68. - name: outback_pv_daily_kwh
  69. state_topic: "outback/mate"
  70. state_class: 'total_increasing'
  71. device_class: energy
  72. unit_of_measurement: kWh
  73. value_template: '{{value_json.summary.pv_daily_Kwh | round(2)}}'

Variant 2: MQTT - Custom Sensors

Add sensors as per your needs in configuration.yaml. Below are examples:

  1. mqtt:
  2. sensor:
  3. ## Sensor for AC input voltage
  4. - name: solar_ac_input_file
  5. state_topic: "outback/mate"
  6. value_template: '{{ value_json.devices[0].ac_input_voltage }}'
  7. unit_of_measurement: "V"
  8. ## Sensor to calculate selling watts
  9. - name: outback_sell_watts
  10. state_topic: "outback/mate"
  11. value_template: '{{(value_json.devices[0].sell_current|int + value_json.devices[1].sell_current|int) * value_json.devices[0].ac_output_voltage|int}}'
  12. unit_of_measurement: 'W'
  13. ## Sensor to calculate buying watts
  14. - name: outback_buy_watts
  15. state_topic: "outback/mate"
  16. value_template: '{{(value_json.devices[0].buy_current|int + value_json.devices[1].buy_current|int) * value_json.devices[0].ac_input_voltage|int}}'
  17. unit_of_measurement: 'W'

Variant 3: JSON File Decoding

Use the file platform integration to decode the JSON file saved by the script. Add the following sensors in configuration.yaml:

  1. sensor:
  2. - platform: file
  3. name: solar_ac_input_file
  4. file_path: /config/www/data/status.json
  5. value_template: '{{ value_json.devices[0].ac_input_voltage }}'
  6. unit_of_measurement: 'V'
  7. - platform: file
  8. name: solar_ac_output_file
  9. file_path: /config/www/data/status.json
  10. value_template: '{{ value_json.devices[0].ac_output_voltage }}'
  11. unit_of_measurement: 'V'

Shell Command (optional)

add in configuration YAML (in below example input_select with desired arguments should be defined)
~~~yaml
shell_command:
script_test_write_mdb: “python /config/phyton_scripts/script_test_summary_mdb.py “
script_outback_change_grid_input_mode: “python3 /media/web/mate3_homeassistant/ChangeMateStatusModBus.py {{states.input_select.solar_grid_input_mode.state}}”
script_outback_change_charger_mode: “python3 /media/web/mate3_homeassistant/ChangeMateStatusModBus.py {{states.input_select.solar_charger_mode.state}}”
script_outback_start_bulk: “python3 /media/web/mate3_homeassistant/ChangeMateStatusModBus.py StartBulk”
script_outback_stop_bulk: “python3 /media/web/mate3_homeassistant/ChangeMateStatusModBus.py StopBulk”
script_outback_start_eq: “python3 /media/web/mate3_homeassistant/ChangeMateStatusModBus.py StartEQ”
script_outback_start_eq: “python3 /media/web/mate3_homeassistant/ChangeMateStatusModBus.py StopEQ”
script_outback_read_mate_status: “python3 /media/web/mate3_homeassistant/ReadMateStatusModBus.py”