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!

Hi @gry2000, firstly regarding your comment about many people using these inverters who are not competent with Linux - If you’re not planning on integrating this with Home Assistant (which is the whole point of the project on Github & this forum thread that you’re posting on) I suggest you just use the Windows Watchpower app - this is what such “non competent linux users” do - You may also find the ASN forums more suitable for your general (non home-assistant related) questions.

Next (and to answer your question) as @nickrout stated - and the readme states, you need to edit the config/mqtt.json file & configure MQTT to suit your environment – If you’re having issues writing/saving the file perhaps you are trying to edit it using your pi’s default (non root) user or a user account that does not have permissions to modify the file - you could try and sudo nano config/mqtt.json - Short of that, you might be best posting a question (such as how to use Vim or Nano what Sudo does etc) on one of the Stackexchange sites where they generally cover these ‘how to use linux’ topics…

Best of luck :slight_smile:

I think the next thing we need to do in this project is make some sort of ‘warning’ parser and then return an array of errors and error codes? (if any) so HA can display them in the UI rather than a long string of numbers…

Happy to accept PR’s :wink:

2 Likes

Haha problem is not the load (I also only sit around 25-30% on Avg) - it’s running the load for 12-13hrs sustained without sun overnight… I’m running a Dual Xeon CPU’s Server setup (so it’s pretty power hungry) with 100TB of disk (There’s 3 Synology Nas’s) :smiley: - Great for transcoding 10+ streams at once and recording local TV, but not exactly lean on the juice … Yes pretty serious setup - It sits in it’s own ‘shed’ out the back of the house - unfortunately power is expensive in AU hence the need for good solar - it’s like $0.22-25c per kw/hr.

1 Like

Yes definitely it will be good to have warning parser. Many thanks for all your work.

Hello @ned-kelly,

No idea why you need so many streams of so much content. Your profile picture appears to indicate you are active and enjoy wakeboarding. I enjoy wakeboarding too. I have a nice mini-itx Lian-Li chassis with 10 hot-swap drive bays and inside I have ASUS Strix B450 with a Ryzan 3 2200g, 16GB ram, 256gb SSD for OS, GTX1060 ITX, RocketRaid 2722 (on a m.2 pci-e adaptor) and a collection of 3 TB WD RED, 4TB RED PRO and some 5TB drive as well. Can handle like 4 to 6 transcodes pretty easily. Will upgrade it to a Ryzen 5 or 7 at some point. Unfortunately this lockdown in South Africa has killed our economy and destroyed businesses. I have been lucky to still have some salary and a job (all be it 50% of each).

On to a question, which files would I need to go into to edit the json discovery config message to include a better friendly name? Or is it best to do the friendly name change from a customize.yaml file in HA?

Do you know of anyone that has done some work with RS485 to MQTT for integrating a purchased BMS to HA? I am seriously struggling to even locate the protocol required to communicate with the BMS. Hoping my supplier actually provides me with some usable information.

Last one is trying to understand the Grafan, HA, InlfuxDB and MariaDB connections. I see that InfluxDB is more meant as a supplement to the HA environment as it does a good job for recording timestamped events but it is not a replacement for the likes of MariaDB (MySQL). Do you use the embedded HA database and have InfluxDB for recording the data of the power system and all other HA data only in the embedded database? Just curious what is the best route to move forward as I need to learn how to do everything from scratch, so having the optimum route forward is useful.

Also are you using the MQTT broker via to Supervisor or have you installed the broker on a seperate machine?

Again thank you for the help and efforts. That goes to all the contributors.

Regards

Wazza

Hello @ned-kelly
This is regarding speed performance improvement.

I just put some additional lprintf comments to main() function in order to identify speed bottleneck and it seems to me that main huge delay is introduced by shell command invoke itself. For example command:

  • docker exec -it voltronic-mqtt bash -c ‘/opt/inverter-cli/bin/inverter_poller -1’
    will introduce 5s till I could see first lprintf message which is placed at the beginning of main() function - right after the curly bracket. All next code output is then provided within 2 seconds including qpigs request to inverter

  • docker exec -it voltronic-mqtt bash -c ‘/opt/inverter-cli/bin/inverter_poller -2’
    This command will invoke inverter_poller just once and then repeatedly (inside the while()) call qpigs to inverter. And this is pretty fast! ~ 2s.

Conclusion/question:

  • I have an idea to implement mqtt commands directly in c++ sources and avoid any other shell scripts except entrypoint.sh of course
  • 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)

I’m now going to study how to compile some linux mqtt c++ library and how to compile, include to docker and use. I have no idea/experiences so far if there is some showstopper hence I’m asking here.
additional notes:

  • I’m using Raspberry pi1 model B+
  • in the test above I’m asking inverter just qpigs

Thanks for any comment / advice.

Hello @ned-kelly

First of all many thanks for your excellent work!

I managed to get all of my Axpert duo 3KVA / 24v inverter data in my home assistant except for the topic “Battery_redischarge_voltage”. Response of inverter_poller is below.

Fri May 1 19:41:34 2020 INVERTER: Debug set
Fri May 1 19:41:34 2020 INVERTER: Current CRC: 49 C1
Fri May 1 19:41:34 2020 INVERTER: QMOD reply size (5 bytes)
Fri May 1 19:41:34 2020 INVERTER: QMOD: 5 bytes read: (L
Fri May 1 19:41:34 2020 INVERTER: QMOD query finished
Fri May 1 19:41:34 2020 INVERTER: Current CRC: B7 A9
Fri May 1 19:41:34 2020 INVERTER: QPIGS reply size (110 bytes)
Fri May 1 19:41:34 2020 INVERTER: QPIGS: 110 bytes read: (234.9 50.0 234.9 50.0 0399 0341 014 344 23.92 000 067 0041 0000 000.0 00.00 00000 10010000 00 00 00000 010
Fri May 1 19:41:34 2020 INVERTER: QPIGS query finished
Fri May 1 19:41:34 2020 INVERTER: Current CRC: F8 54
Fri May 1 19:41:35 2020 INVERTER: QPIRI reply size (102 bytes)
Fri May 1 19:41:35 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 2 3 0 11 0 0 24.5 0 1 080
Fri May 1 19:41:35 2020 INVERTER: QPIRI query finished
Fri May 1 19:41:35 2020 INVERTER: Current CRC: B4 DA
Fri May 1 19:41:35 2020 INVERTER: QPIWS reply size (36 bytes)
Fri May 1 19:41:35 2020 INVERTER: QPIWS: incorrect start/stop bytes. Buffer: (0000000000000000000000000000000000B0 24.0 22.5 21.0 30.6 29.2 2 30 040 0 2 3 0 11 0 0 24.5 0 1 080
INVERTER: ampfactor from config is 1.00
INVERTER: wattfactor from config is 1.01
{
“Inverter_mode”:3,
“AC_grid_voltage”:234.9,
“AC_grid_frequency”:50.0,
“AC_out_voltage”:234.9,
“AC_out_frequency”:50.0,
“PV_in_voltage”:0.0,
“PV_in_current”:0.0,
“PV_in_watts”:0.0,
“PV_in_watthour”:0.0000,
“SCC_voltage”:0.0000,
“Load_pct”:14,
“Load_watt”:341,
“Load_watthour”:11.3667,
“Load_va”:399,
“Bus_voltage”:344,
“Heatsink_temperature”:41,
“Battery_capacity”:67,
“Battery_voltage”:23.92,
“Battery_charge_current”:0,
“Battery_discharge_current”:0,
“Load_status_on”:1,
“SCC_charge_on”:0,
“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”:2,
“Charger_source_priority”:3,
“Battery_redischarge_voltage”:2508860039157362365701836016451584.0,
“Warnings”:""

As you can see, “QPIWS: incorrect start/stop bytes…” appears in the result along with battery discharge voltage some junk value. Except for QPIRI all values are default. QPIRI had to be 102 to get it working. I tried to publish payload “26” to battery_redischarge_voltage_conf without success. Any suggestion?

Anyone else experience this issue?

Another request to fellow members is, if anyone willing to share Grafana dashboard exports for this project, please let me know. I have some basic ones going but not quite satisfied.

Regards

Hello People,

Does anyone else have any issues that when you restart HA you lose your connection to the voltronic MQTT? Is there something I should do like adding a scripti or service call on HA startup?

I currently have to go to the MQTT integration after restart and select update for it to recognise all the sensors. Then after 30 seconds the data is back again.

Regards

Wazza

Hello @rejishkr

I guess that you have to correct qpiws value to see all correctly. But as I have no 3kva inverter I can just advise you to try value 38. (if still *incorrect start/stop bytes* issue observed, please try values 40 and 39). in case you will make it working then it will be good to share your exact

- inverter firmware versions, 
- final correct buffers values and 
- *inverter_poller* log 

(for others if @ned-kelly will agree)

1 Like

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