Programmatically read data from your Solar Inverter (Voltronic, Axpert, Mppsolar PIP, Voltacon, Effekta etc) and interface with Home Assistant via MQTT - Works with RS232 & USB!

Thanks @Lee1 for the prompt reply!

With qpiws value 38, incorrect start/stop bytes issue is resolved, so I guess it must be the correct value. However, Battery_redischarge_voltage is still showing strange values. Each time I poll, the value is different, for same settings. Here is the inverter_poller and other details you asked.

  • inverter firmware version - Main CPU: 00018.16 , CPU2: 00003.25
  • final buffers value: qpiri=102, qpiws=38, qmod=5, qpigs=110
  • inverter_poller log

Sat May 2 04:41:16 2020 INVERTER: Debug set
Sat May 2 04:41:16 2020 INVERTER: Current CRC: 49 C1
Sat May 2 04:41:17 2020 INVERTER: QMOD reply size (5 bytes)
Sat May 2 04:41:17 2020 INVERTER: QMOD: 5 bytes read: (B
Sat May 2 04:41:17 2020 INVERTER: QMOD query finished
Sat May 2 04:41:17 2020 INVERTER: Current CRC: B7 A9
Sat May 2 04:41:17 2020 INVERTER: QPIGS reply size (110 bytes)
Sat May 2 04:41:17 2020 INVERTER: QPIGS: 110 bytes read: (226.2 50.0 230.5 50.0 0436 0289 014 323 22.79 000 037 0036 0009 072.6 22.89 00005 10010110 00 00 00217 010
Sat May 2 04:41:17 2020 INVERTER: QPIGS query finished
Sat May 2 04:41:17 2020 INVERTER: Current CRC: F8 54
Sat May 2 04:41:18 2020 INVERTER: QPIRI reply size (102 bytes)
Sat May 2 04:41:18 2020 INVERTER: QPIRI: 102 bytes read: (230.0 13.0 230.0 50.0 13.0 3000 2400 24.0 22.5 21.0 30.6 29.2 2 30 040 0 1 1 0 11 0 0 24.5 0 1 080
Sat May 2 04:41:18 2020 INVERTER: QPIRI query finished
Sat May 2 04:41:18 2020 INVERTER: Current CRC: B4 DA
Sat May 2 04:41:18 2020 INVERTER: QPIWS reply size (38 bytes)
Sat May 2 04:41:18 2020 INVERTER: QPIWS: 38 bytes read: (0000000000000000000000000000000000
Sat May 2 04:41:18 2020 INVERTER: QPIWS query finished
INVERTER: ampfactor from config is 1.00
INVERTER: wattfactor from config is 1.01
{
“Inverter_mode”:4,
“AC_grid_voltage”:226.2,
“AC_grid_frequency”:50.0,
“AC_out_voltage”:230.5,
“AC_out_frequency”:50.0,
“PV_in_voltage”:72.6,
“PV_in_current”:9.0,
“PV_in_watts”:208.1,
“PV_in_watthour”:6.9357,
“SCC_voltage”:22.8900,
“Load_pct”:14,
“Load_watt”:289,
“Load_watthour”:9.6333,
“Load_va”:436,
“Bus_voltage”:323,
“Heatsink_temperature”:36,
“Battery_capacity”:37,
“Battery_voltage”:22.79,
“Battery_charge_current”:0,
“Battery_discharge_current”:5,
“Load_status_on”:1,
“SCC_charge_on”:1,
“AC_charge_on”:0,
“Battery_recharge_voltage”:22.5,
“Battery_under_voltage”:21.0,
“Battery_bulk_voltage”:30.6,
“Battery_float_voltage”:29.2,
“Max_grid_charge_current”:30,
“Max_charge_current”:40,
“Out_source_priority”:1,
“Charger_source_priority”:1,
“Battery_redischarge_voltage”:2489211454853824809978637116768256.0,
“Warnings”:“0000000000000000000000000000000000”
}
Sat May 2 04:41:18 2020 INVERTER: All queries complete, exiting loop.

My worry would be, if this will have a bad impact on output switching decisions from utility to solar and vice-versa.

1 Like

Hi Everyone

Thanks to everyone for the input here. It helped me finally get this working.The only issue I have is that I see the MQTT messages from the app are posted every 40 seconds. Change interval is set to 240 and I’ve tried changing the entrypoint.sh to run at the same interval, but no difference. The Pi is connected to the Inverter using USB.

Anyone have any idea why that is?

Thanks in advance.

Hi @skefda yes, I already did some investigation around and my findings are few forum comments above.
Please see this.
I’m now trying to convert mqtt directly into C++ so that from entrypoint.sh will call inverter_poller just once. But I’m still waiting comments from @ned-kelly/others in parallel to that idea.

2 Likes

mine has the same crazy number for the redischarge value i wouldnt worry it doesnt affect anything controling the unit

I run MariaDB for the main DB instead of the built in SQL lite db. Provides better access speeds to the recorder and state history. Then InfluxDB installed and integrated into HA with default settings. All that does is then mirror MariaDB. Grafana is then configured to use InfluxDB as a source.

Also live in SA myself… this lock-down is beginning to stretch my patience!

Stay Safe

2 Likes

As such it doesn’t, but by adjusting this value, I could override the discharging threshold and there by forcing the inverter to continue in battery or switchover to grid, regardless of required healthy operational battery voltage in my opinion.

I have restarted a few times after completing the configuration and each time it came back good without having to do any manual update. Please note that there is an inherent delay in receiving / sending data (at least for me) so you wait for while before manual update.

@Waz-Cpt:

which files would I need to go into to edit the json discovery config message to include a better friendly name

You’ll need to edit all the shell scripts - they just read the JSON file and then those args feed into mosquitto_sub / pub - the actual C app just spits out a raw JSON file there’s currently no MQTT logic in the C App.

Do you know of anyone that has done some work with RS485 to MQTT for integrating a purchased BMS to HA?

I’ve done this actually for a cheap 2nd MPPT Controller I had before it got rid of it and got 2x EPEVER ones (My panels are on different pitches and directions hence the need for multiple MPPT trackers)… Basically you’ll just need to get ahold of the protocol manual - then you should be able to just talk to the BMS just using a terminal (with the right baud rate etc) - then once you’ve worked out what commands you need, you will just need to create a program that can send the commands and parse the arguments, and send it back to HA (Essentially this is exactly what and how this project actually works)

Last one is trying to understand the Grafan, HA, InlfuxDB and MariaDB connections.

I’m using InfluxDB in conjunction with the default HA SQLite Database - Basically my Sqlite database only stores 24 hours of data - all data, however gets logged into InfluxDB - This allows me to create ‘detailed’ Grafana dashboards for things i want to “deep dive” into - and create my own HA Dashboards for my Smart devices (Wall tablets, iPhone app etc) for quick viewing of the house and regular daily usage…

My MQTT Broker, Home Assistant, Grafana, Influx DB, etc all run in their own ‘standalone’ docker containers on a host - that way i can easily upgrade and backup any single component (container) at any time I wish without too much stuffing around…

I used to manually install apps onto bare metal years ago, but as I live near the beach my hardware regularly breaks (after a few years of salt air) so putting everything into docker containers and being able to quickly rebuild an environment is a key requirement for me.

Hope this helps shed some light and good luck with your setup!

Oh PS - My Plex setup is shared with a few Neighbors and we have a UBNT Mesh & Nanobeam network between our houses hence the big setup.

@Lee1

Great to see you’re seeing how to improve the project!

So to start - The initial time to establish a connection to the inverter is a few seconds (the first connection sets the serial rate etc and the inverter seems to take a while to respond) - this is the delay…

  • I have an idea to implement mqtt commands directly in c++ sources and avoid any other shell scripts except entrypoint.sh of course

I originally started heading down this route but the project was a quick and dirty weekend job and it’s going to be a fair bit of work to embed a native MQTT library in the app that should work with every major architecture (Hence just opting to spit out a JSON response, then parse the json and send it with Mosquitto MQTT)… Currently as the project stands, it can be compiled for Linux, Mac, and Windows and it’s pretty bulletproof.

If you’re keen to bite off including MQTT in project, we’ll need to include MQTT Libraries that also support SSL (since a lot of MQTT Setups use SSL now days), which will probably require OpenSSL Libraries etc - so the overall size and complexity of building the project, as well as maintaining releases (every time OpenSSL is patched due to vulnerabilities) will increase a lot).

  • is there some reason why this solution is based on combination of C++ & shell please? (I hope that reason is that c++ sources were just more-less reused from manio’s skymax)

The original python and node variants I’ve tried and tested out there on Github DON’T play nice with the Serial adapter (Trust me, I tested about 3-4 projects before starting this one) - they seem to only reliably work with the USB port - I opted to base this from manio’s C project originally since it works reliably with both the USB and Serial ports. For those who don’t know - there’s a bug in the firmware with the USB sending payloads larger than 8 bytes - so if you have an array of inverters or a 5KW version which supports more configuration parameters than the 12/24v versions you’ll need to use the Serial connection (not the USB) to configure some of the arguments. Hopefully it gets fixed in the 2020 releases of this inverter from China, since some of them are dropping Serial ports now.

Anyway if you want to start seriously looking at the dev side of this, let’s move these discussions over to Github and create a fork and then we can merge your branch for testing when you’re happy with your changes.

1 Like

Hi @Wazza & @rejishkr (PS Welcome to Home Assistant Forums @rejishkr)

When you restart HA, the MQTT sensors are lost (because they are auto-added and not manually specified in your HA YAML file) - The voltronic container will send a command to ‘re-create’ the sensors every 5 minutes, which is why they automatically come back.

You won’t lose any data - but if restarting HA and not wanting to wait a few mintues for the sensors to come back is a deal-breaker you’ll probably want to manually create them in your HA YAML file :slight_smile:

Hi All - due to many PM’s for the Grafana Dashboard I’ve included an export in the project’s github at: https://github.com/ned-kelly/docker-voltronic-homeassistant/blob/774606e5e65cc4791a3800962330dbc4f42a82e7/homeassistant/grafana_dashboard.json

Note that I’m actually waiting for a “CT Clamp Board” from France (Ordered about a month ago) which I’m waiting to integrate into the solution so I can monitor individual circuits, consumption from the grid etc - I’ll update the HA Dashboard and the Grafana Dashboard once I’ve got it integrated - as well as some sort of writeup on the build required for anyone else looking to replicate. (Hopefully it arrives soon!)

If anyone else has made some better (or different) Grafana dashboard layouts, please also feel free to also add into the Github project along with a screenshot :slight_smile:

3 Likes

Hi guys!
I was running the app on orange pi zero with armbian and usb<>serial converter on ttyUSB0. One day the orange pi dropped from the wifi network. I’ve switched to the ethernet and try to run again but now I get
Mon May 4 20:24:16 2020 INVERTER: Current CRC: B7 A9
Mon May 4 20:24:19 2020 INVERTER: QPIGS read timeout
Mon May 4 20:24:19 2020 INVERTER: QPIGS reply too short (8 bytes)
Mon May 4 20:24:19 2020 INVERTER: Current CRC: F8 54
Mon May 4 20:24:22 2020 INVERTER: QPIRI read timeout
Mon May 4 20:24:22 2020 INVERTER: QPIRI reply too short (7 bytes)
Mon May 4 20:24:22 2020 INVERTER: Current CRC: B4 DA
Mon May 4 20:24:25 2020 INVERTER: QPIWS read timeout
Mon May 4 20:24:25 2020 INVERTER: QPIWS reply too short (7 bytes)
Mon May 4 20:24:30 2020 INVERTER: Current CRC: 49 C1
Mon May 4 20:24:33 2020 INVERTER: QMOD read timeout
Mon May 4 20:24:33 2020 INVERTER: QMOD reply too short (3 bytes)
Mon May 4 20:24:33 2020 INVERTER: Current CRC: B7 A9
Mon May 4 20:24:36 2020 INVERTER: QPIGS read timeout
Mon May 4 20:24:36 2020 INVERTER: QPIGS reply too short (5 bytes)
Mon May 4 20:24:36 2020 INVERTER: Current CRC: F8 54
Mon May 4 20:24:39 2020 INVERTER: QPIRI read timeout
Mon May 4 20:24:39 2020 INVERTER: QPIRI reply too short (7 bytes)
Mon May 4 20:24:39 2020 INVERTER: Current CRC: B4 DA
Mon May 4 20:24:42 2020 INVERTER: QPIWS read timeout
Mon May 4 20:24:42 2020 INVERTER: QPIWS reply too short (7 bytes)
Mon May 4 20:24:47 2020 INVERTER: Current CRC: 49 C1
Mon May 4 20:24:47 2020 INVERTER: QMOD reply size (5 bytes)
…00 . 500 48.0 46.042.0 .4 5 0 30 050 0 0 2 6 004.0 0 1%▒p bytes. Buffer: (NAKs▒

I am unable to get it running. My setup is the same as before (when it ran ok):
qpiri=98
qpiws=36
qmod=5
qpigs=110

I have tried swapping to the USB<>serial converter, but the result is the same. Is there any way to remedy this?

Reboot the Pi, and try and set the serial port’s rate/speed to 2400:

stty -F /dev/ttyUSB0 2400 raw

Then reboot the docker container and see how you go

this did not help:( …
then I read a bit about stty utility and did sudo stty sane, then sudo stty -F /dev/ttyUSB0 2400 raw - and that helped!

1 Like

Hi @ned-kelly, I updated my firmware on my inverter to version 73.00e last night. Since then I am not getting any data from the inverter. Was there something I needed to change in your code after the update?

Hello @Waz-Cpt may be that buffer lengths were changed? Can you please run command:
docker exec -it voltronic-mqtt bash -c '/opt/inverter-cli/bin/inverter_poller -d -1'
and check if there are some errors regarding incorrect start/stop bytes?

@Lee1, I will do so when I get remote access to my house again.

This is regarding speed performance improvement.
Hello @ned-kelly many thanks for all very useful comments.
So far I was able to improve values refresh interval in home assistant up to 3-4secs.
Changes done:

  1. bought raspberry pi4 and used instead of raspberry pi1 :slight_smile:
  2. in entrypoint.sh
watch -n 30 /opt/inverter-mqtt/mqtt-push.sh > /dev/null 2>&1
changed to:
watch -n 0 /opt/inverter-mqtt/mqtt-push.sh > /dev/null 2>&1
  1. in mqtt_push.sh grouped rows which are inicializing variables togheder:
Inverter_mode=`echo $INVERTER_DATA | jq '.Inverter_mode' -r`
AC_grid_voltage=`echo $INVERTER_DATA | jq '.AC_grid_voltage' -r`
...
Warnings=`echo $INVERTER_DATA | jq '.Warnings' -r`

and grouped also rows which are publishing values to mqtt server together and added “&” at the end of each of this row so that script will not wait for messages publishing and will do that in the background:

[ ! -z "$Inverter_mode" ] && pushMQTTData "Inverter_mode" "$Inverter_mode" &
[ ! -z "$AC_grid_voltage" ] && pushMQTTData "AC_grid_voltage" "$AC_grid_voltage" &
....
[ ! -z "$Warnings" ] && pushMQTTData "Warnings" "$Warnings" &

That’s all. So this is enough for me so far. Next I’ll try to modify shell script in a way that only changed values will be published to server in order to minimize communication, but firs of all I’ll learn how to publish these modifications on github so that you could merge for others. I know that also some wait should be introduced to make mqtt more safe but wanted to share with others this workaround.

2 Likes

Hello @Lee1,

Here is the output from the command you gave me.

warwick@linux-server:~$ sudo docker exec -it voltronic-mqtt bash -c '/opt/invert                                  er-cli/bin/inverter_poller -d -1'
[sudo] password for warwick:
Tue May  5 14:50:44 2020 INVERTER: Debug set
Tue May  5 14:50:44 2020 INVERTER: Unable to open device file (errno=2 No such file or directory)
Tue May  5 14:50:49 2020 INVERTER: Unable to open device file (errno=2 No such file or directory)
Tue May  5 14:50:54 2020 INVERTER: Unable to open device file (errno=2 No such file or directory)

EDIT: Restarted Computer

warwick@linux-server:~$ sudo docker exec -it voltronic-mqtt bash -c '/opt/inverter-cli/bin/inverter_poller -d -1'
Tue May  5 15:25:48 2020 INVERTER: Debug set
Tue May  5 15:25:48 2020 INVERTER: Current CRC: 49 C1
Tue May  5 15:25:48 2020 INVERTER: QMOD reply size (5 bytes)
Tue May  5 15:25:48 2020 INVERTER: QMOD: 5 bytes read: (L
Tue May  5 15:25:48 2020 INVERTER: QMOD query finished
Tue May  5 15:25:48 2020 INVERTER: Current CRC: B7 A9
Tue May  5 15:25:48 2020 INVERTER: QPIGS reply size (110 bytes)
Tue May  5 15:25:48 2020 INVERTER: QPIGS: 110 bytes read: (230.4 49.8 230.4 49.8 0806 0785 019 426 52.80 000 079 0052 0000 079.3 52.85 00000 00010110 00 00 00026 010
Tue May  5 15:25:48 2020 INVERTER: QPIGS query finished
Tue May  5 15:25:48 2020 INVERTER: Current CRC: F8 54
Tue May  5 15:25:49 2020 INVERTER: QPIRI reply size (98 bytes)
Tue May  5 15:25:49 2020 INVERTER: QPIRI: incorrect start/stop bytes.  Buffer: (230.0 21.7 230.0 50.0 21.7 5000 4000 48.0 51.0 48.2 56.4 54.0 2 10 120 1 2 1 9 01 0 0 54.0 1 1 0000026 010
Tue May  5 15:25:49 2020 INVERTER: Current CRC: B4 DA
Tue May  5 15:25:49 2020 INVERTER: QPIWS reply size (36 bytes)
Tue May  5 15:25:49 2020 INVERTER: QPIWS: 36 bytes read: (00000000000000000000000000000000
Tue May  5 15:25:49 2020 INVERTER: QPIWS query finished
Tue May  5 15:25:54 2020 INVERTER: Current CRC: F8 54
Tue May  5 15:25:55 2020 INVERTER: QPIRI reply size (98 bytes)
Tue May  5 15:25:55 2020 INVERTER: QPIRI: incorrect start/stop bytes.  Buffer: (230.0 21.7 230.0 50.0 21.7 5000 4000 48.0 51.0 48.2 56.4 54.0 2 10 120 1 2 1 9 01 0 0 54.0 1 1 0000026 010
Tue May  5 15:26:00 2020 INVERTER: Current CRC: F8 54
Tue May  5 15:26:00 2020 INVERTER: QPIRI reply size (98 bytes)
Tue May  5 15:26:00 2020 INVERTER: QPIRI: incorrect start/stop bytes.  Buffer: (230.0 21.7 230.0 50.0 21.7 5000 4000 48.0 51.0 48.2 56.4 54.0 2 10 120 1 2 1 9 01 0 0 54.0 1 1 0000026 010

Regards

Warwick

Hi @Lee1

I’ve applied the changes you posted now, on my setup and haven’t seen any difference. Still seeing a 40 second delay between MQTT messages. Only difference in my setup is I run this on a Pi3B+.

Any other ideas?