Skip to content

Programmatically read data from your Voltronic, Axpert, Mppsolar PIP, Voltacon, Effekta etc Inverter and send it to Home Assistant via MQTT - Works with RS232 & USB!

License

Notifications You must be signed in to change notification settings

gadget78/inverter-homeassistant

 
 

Repository files navigation

A Docker based Home Assistant interface for MPP/Voltronic/Iconica Solar Inverters

License Docker Pulls buildx


This project was derived from the 'skymax' C based monitoring application and then from ned-kelly's designed to take the monitoring data from Voltronic, Axpert, Mppsolar PIP, Voltacon, Effekta, Iconica and other branded OEM Inverters and send it to a Home Assistant MQTT server for ingestion...

The program can also receive commands from Home Assistant (via MQTT) to change the state of the inverter remotely.

By remotely setting values via MQTT you can implement many more complex forms of automation (triggered from Home Assistant) such as:

  • Changing the power mode to 'solar only' during the day, but then change back to 'grid mode charging' for your AGM or VLRA batteries in the evenings, but if it's raining (based on data from your weather station), set the charge mode to PCP02 (Charge based on 'Solar and Utility') so that the following day there's plenty of juice in your batteries...

  • Programatically set the charge & float voltages based on additional sensors (such as a Zigbee Temperature Sensor, or a DHT-22 + ESP8266) - This way if your battery box is too hot/cold you can dynamically adjust the voltage so that the batteries are not damaged...

  • Dynamically adjust the inverter's "solar power balance" and other configuration options to ensure that you get the most "bang for your buck" out of your setup...


The program is designed to be run in a Docker Container, and can be deployed on a lightweight SBC next to your Inverter (i.e. an Orange Pi Zero running Arabian), and read data via the RS232 or USB ports on the back of the Inverter.

Example Lovelace Dashboard Example #1: nedkelly's"Lovelace" dashboard using data collected from the Inverter & the ability to change modes/configuration via MQTT.

Example Lovelace Dashboard Example #2: nedkelly's Grafana summary allowing more detailed analysis of data collected, and the ability to 'deep-dive' historical data.

Prerequisites

Configuration & Standing Up

It's pretty straightforward, just clone down the sources and set the configuration files in the config/ directory:

# Clone down sources on the host you want to monitor...
git clone https://github.com/gadget78/docker-voltronic-homeassistant.git /opt/ha-inverter-mqtt-agent

# Change directory to the downloaded source
cd /opt/ha-inverter-mqtt-agent

# next Configure the 'device=' parameter to suit for RS232 or USB etc (info in file).. 
# Leave the rest the same for now 
# (how to use/save nano is printed at bottom, ctrl+x for exit, with prompt tosave)
nano config/inverter.conf

# Configure your MQTT server's IP/Host Name, Port, Credentials, HA topic, and name of the Inverter that you want displayed in Home Assistant...
# If your MQTT server does not need a username/password just make something up (emtpy field in password can trip the topic parameter up).
nano config/mqtt.json

Then, plug in your Serial or USB cable to the Inverter & stand up the container:

docker-compose up -d

Note:

  • builds on docker hub are currently for linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386 -- If you have issues standing up the image on your Linux distribution (i.e. An old Pi/ARM device) you may need to manually build the image to support your local device architecture - This can be done by uncommenting the build flag in your docker-compose.yml file.

there are other option in docker-compose.yml like Watchtower, which can be configured to auto-update this image when we push new changes to github

Integrating into Home Assistant.

Providing you have setup MQTT with Home Assistant, the device will automatically register in your Home Assistant when the container starts for the first time -- You do not need to manually define any sensors/or devices.

and if all went ok, goto configuration in homeassistant, you should now see 1 more item in MQTT inigrations device, or just go direct in the devices tab, selecting whatever you named it in the mqtt.json config file... should then give you a list to add to lovelace...

From here you can setup Graphs to display sensor data, and optionally change state of the inverter by "publishing" a string to the inverter's primary topic like so:

Example, Changing the Charge Priority Example: Changing the Charge Priority of the Inverter

COMMON COMMANDS THAT CAN BE SENT TO THE INVERTER

(see protocol manual for complete list of supported commands)

DESCRIPTION:                PAYLOAD:  OPTIONS:
----------------------------------------------------------------
Set output source priority  POP00     (Utility first)
                            POP01     (Solar first)
                            POP02     (SBU)

Set charger priority        PCP00     (Utility first)
                            PCP01     (Solar first)
                            PCP02     (Solar and utility)
                            PCP03     (Solar only)

Set the Charge/Discharge Levels & Cutoff
                            PBDV26.9  (Don't discharge the battery unless it is at 26.9v or more)
                            PBCV24.8  (Switch back to 'grid' when battery below 24.8v)
                            PBFT27.1  (Set the 'float voltage' to 27.1v)
                            PCVV28.1  (Set the 'charge voltage' to 28.1v)

Set other commands          PEa / PDa (Enable/disable buzzer)
                            PEb / PDb (Enable/disable overload bypass)
                            PEj / PDj (Enable/disable power saving)
                            PEu / PDu (Enable/disable overload restart);
                            PEx / PDx (Enable/disable backlight)

NOTE: When setting/configuring your charge, discharge, float & cutoff voltages for the first time, it's worth understanding how to optimize charging conditions to extend service life of your battery: https://batteryuniversity.com/learn/article/charging_the_lead_acid_battery

Using inverter_poller binary directly

This project uses heavily modified sources, from manio's original demo, and be compiled to run standalone on Linux, Mac, and Windows (via Cygwin).

Just head to the sources/inverter-cli directory and build it directly using: cmake . && make.

Basic arguments supported are:

USAGE:  ./inverter_poller <args> [-r <command>], [-h | --help], [-1 | --run-once]

SUPPORTED ARGUMENTS:
          -r <raw-command>      TX 'raw' command to the inverter
          -h | --help           This Help Message
          -1 | --run-once       Runs one iteration on the inverter, and then exits
          -d                    Additional debugging

Tips/Help

when you first run the container, it will populate the homeassistant MQTT topic with auto discovery configs... if this does not happen your setup is incorrect somewhere (network etc)

if you see the MQTT topics populate, but there is no data along with them (can take a few minuets at forst to get things rolling) then it could be a problem with polling your inverter use the invert_poller app thats created... by either sudo docker exec -it inverter bash -c '/opt/inverter-cli/bin/inverter_poller -d -1' or going direct to the terminal/console from within the container, using a say portainer

this will give feedback on what the invert_poller prigram is doing/getting back from the inverter.. then using the info given here can help you adjust the inverter.conf file to get communication working...

Bonus: Lovelace Dashboard Files

Please refer to the screenshot above for an example of the dashboard.

I've included some Lovelace dashboard files in the homeassistant/ directory, however you will need to need to adapt to your own Home Assistant configuration and/or name of the inverter if you have changed it in the mqtt.json config file.

Note that in addition to merging the sample Yaml files with your Home Assistant, you will need the following custom Lovelace cards installed if you wish to use my templates:

About

Programmatically read data from your Voltronic, Axpert, Mppsolar PIP, Voltacon, Effekta etc Inverter and send it to Home Assistant via MQTT - Works with RS232 & USB!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 62.8%
  • Shell 35.3%
  • C 1.3%
  • CMake 0.6%