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!

you could try, i dunno what advise to give you. read all the message from here and hope you will figure out. good luck

Why my tool works fine with /dev/hidraw0 but i receive a (NAKss if i use /dev/ttyUSB0 ?

to test if the adapter is working on raspberry, i tried to use picocom and it works fine:

Update on my issue with /dev/ttyUSB0

if i set the baudrate before dorker up it works fine:

pi@solarpi:~/cb.docker-voltronic-homeassistant $ stty -F /dev/ttyUSB0 2400
pi@solarpi:~/cb.docker-voltronic-homeassistant $ docker-compose up -d
1 Like

Great! You find it! If I remember ned kelly said something about that for serial. Try to make something that every time you restart the pi to do that.

Yes, i wrote a pyhton script that do this:

import serial

serialport = serial.Serial("/dev/ttyUSB0", 2400, timeout=0.5)
        
serialport.write(b"QMOD 4\r")
response = serialport.readlines(None)
print(response)

serialport.write(b"QPIGS 5\r")
response = serialport.readlines(None)
print(response)
        

and insterted into the crontab at boot:

@reboot python set_ttyUSB0.py > /home/pi/out.txt

and it works fine.

1 Like

Hello! Set up the container but i cant get it connected on mqtt. i’m using a raspberry pi 3 b+ with last version of pi os. In sudo docker exec -it voltronic-mqtt bash -c ‘/opt/inverter-cl i/bin/inverter_poller -d -1’ i obtain this response:

pi@raspberrypi:/opt/ha-inverter-mqtt-agent $ docker exec -it voltronic-mqtt bash -c '/opt/inverter-cli/bin/inverter_poller -d -1'
Tue Jun 14 08:46:24 2022 INVERTER: Debug set
Tue Jun 14 08:46:24 2022 INVERTER: Current CRC: 49 C1
Tue Jun 14 08:46:24 2022 INVERTER: QMOD reply size (5 bytes)
Tue Jun 14 08:46:24 2022 INVERTER: QMOD: 5 bytes read: (B
Tue Jun 14 08:46:24 2022 INVERTER: QMOD query finished
Tue Jun 14 08:46:24 2022 INVERTER: Current CRC: B7 A9
Tue Jun 14 08:46:24 2022 INVERTER: QPIGS reply size (110 bytes)
Tue Jun 14 08:46:24 2022 INVERTER: QPIGS: 110 bytes read: (000.0 00.0 230.2 50.0 0000 0000 000 373 26.94 006 100 0031 0006 059.4 27.00 00000 00110110 00 00 00166 110
Tue Jun 14 08:46:24 2022 INVERTER: QPIGS query finished
Tue Jun 14 08:46:24 2022 INVERTER: Current CRC: F8 54
Tue Jun 14 08:46:25 2022 INVERTER: QPIRI reply size (98 bytes)
Tue Jun 14 08:46:25 2022 INVERTER: QPIRI: 98 bytes read: (230.0 13.0 230.0 50.0 13.0 3000 3000 24.0 23.0 21.5 28.2 27.0 0 30 060 0 1 2 1 01 0 0 27.0 0 1
Tue Jun 14 08:46:25 2022 INVERTER: QPIRI query finished
Tue Jun 14 08:46:25 2022 INVERTER: Current CRC: B4 DA
Tue Jun 14 08:46:25 2022 INVERTER: QPIWS reply size (36 bytes)
Tue Jun 14 08:46:25 2022 INVERTER: QPIWS: 36 bytes read: (00000100000000000000000000000000
Tue Jun 14 08:46:25 2022 INVERTER: QPIWS query finished
INVERTER: ampfactor from config is 1.00
INVERTER: wattfactor from config is 1.01
{
  "Inverter_mode":4,
  "AC_grid_voltage":0.0,
  "AC_grid_frequency":0.0,
  "AC_out_voltage":230.2,
  "AC_out_frequency":50.0,
  "PV_in_voltage":59.4,
  "PV_in_current":6.0,
  "PV_in_watts":163.6,
  "PV_in_watthour":5.4540,
  "SCC_voltage":27.0000,
  "Load_pct":0,
  "Load_watt":0,
  "Load_watthour":0.0000,
  "Load_va":0,
  "Bus_voltage":373,
  "Heatsink_temperature":31,
  "Battery_capacity":100,
  "Battery_voltage":26.94,
  "Battery_charge_current":6,
  "Battery_discharge_current":0,
  "Load_status_on":1,
  "SCC_charge_on":1,
  "AC_charge_on":0,
  "Battery_recharge_voltage":23.0,
  "Battery_under_voltage":21.5,
  "Battery_bulk_voltage":28.2,
  "Battery_float_voltage":27.0,
  "Max_grid_charge_current":30,
  "Max_charge_current":60,
  "Out_source_priority":1,
  "Charger_source_priority":2,
  "Battery_redischarge_voltage":2532947876441777295090823175602176.0,
  "Warnings":"00000100000000000000000000000000"
}

So i assume that the software is communicating correctly with the inverter. But i cant get connected to the mosquitto broker, i cant see any new connection.

if i log the container i see this response

pi@raspberrypi:/opt/ha-inverter-mqtt-agent $ docker container logs voltronic-mqtt
Unable to connect (Lookup error.).
Unable to connect (Lookup error.).
Unable to connect (Lookup error.).
Unable to connect (Lookup error.).
Unable to connect (Lookup error.).
Unable to connect (Lookup error.).
Unable to connect (Lookup error.).

Since i have 2 containers running, one with this software and one with home assistant and mosquitto, i think it could be a networking issue, but since i’m not very expert i don’t know how to solve it. I also tried to connect voltronic-mqtt to a cloud hivemq broker but it cant connect. here is the response of the container ps:

pi@raspberrypi:/opt/ha-inverter-mqtt-agent $ docker container ps
CONTAINER ID   IMAGE                                          COMMAND                  CREATED        STATUS                    PORTS                                       NAMES
d892725cd300   bushrangers/ha-voltronic-mqtt                  "/bin/bash /opt/inve…"   12 hours ago   Up 12 hours (unhealthy)                                               voltronic-mqtt
475461e8dac3   containrrr/watchtower                          "/watchtower --inter…"   12 hours ago   Up 12 hours               8080/tcp                                    watchtower
cc1a2c311d4b   eclipse-mosquitto                              "/docker-entrypoint.…"   17 hours ago   Up 15 minutes             0.0.0.0:1883->1883/tcp, :::1883->1883/tcp   mosquitto
d6b07c4a1350   ghcr.io/home-assistant/home-assistant:stable   "/init"                  34 hours ago   Up 15 minutes                                                         home-assistant

and here is the response of the docker compose ls

pi@raspberrypi:/opt/ha-inverter-mqtt-agent $ docker compose ls
NAME                     STATUS              CONFIG FILES
esempio-compose          running(2)          docker-compose.yaml
ha-inverter-mqtt-agent   running(2)          docker-compose.yml

hope somene can help me! if you need more information let me know!
thanks

hi,
I have HA on separate machine.
but why you have mosquitto on separate docker? HA has an add-on called mosquitto broker. follow instructions for this add-on and then configure mqtt.json with new variables(the IP should be the ip of HA).

hi!
I installed the core version of home assistant and as far i know (but i’m a newbie) i cant install addons like the supervised installation, but i have to put it in another container

ok, it is over me regarding knowledge…
so you have to know the ip of this docker of mqtt…
to test if it is ok you can use mqtt explorer(it is windows version) to connect to this broker and see if you have topic registered.
then you have to figure out how HA will connect to this broker to read data.

Thanks for you help! its weird because i the broker its working, hassio comunicate with it and i tried to connect another inverter application (solpiplog) and it connects properly to the broker! I think its a voltronic-mqtt issue but i dont know how to solve it!

in my fork, in mqtt.conf
you have to change:
“server”: “192.168.0.2”,
“port”: “1883”,
“devicename”: “mpp”,
“serial”: “92331908103079”,
“username”: “mqtt”,
“password”: “broker”,

then HA it will discover automatically in mqtt devices.
if you have ned-kelly then:
“server”: “[HA_MQTT_IP]”,
“port”: “1883”,
“topic”: “homeassistant”,
“username”: “”,
“password”: “”,
“clientid”: “voltronic_bd8041d0cdf131a6ba4e5b3360b8bc5a”,
after that, wait 5 miniutes to show in HA, and you have to look for sensors.

I tried your fork, but this is the response of docker exec -it voltronic-mqtt bash -c ‘/opt/inverter-cl i/bin/inverter_poller -d -1’:

# The following settings allow you to modify runtime buffers.
# N.B. These values may not be applicable to all inverter t
Tue Jun 14 13:49:57 2022 INVERTER: Current CRC: F8 54
Tue Jun 14 13:49:57 2022 INVERTER: QPIRI reply size (0 bytes)
Tue Jun 14 13:49:57 2022 INVERTER: QPIRI: incorrect start/stop bytes.  Buffer: Qconfiguration options for the actual inverter polling process...

# The device to read from...
# Use: /dev/ttyS0 if you have a serial device,
#      /dev/ttyUSB0 if a USB<>Serial,
#      /dev/hidraw0 if you're connecting via the USB port on the inverter.

device=/dev/hidraw0

# How many times per hour is the program going to run...
# This is used to calculate the PV & Load Watt Hours between runs...
# If unsure, leave as default - it will run every minute...

# (120 = every 30 seconds)...
# run_interval=322 don;t need it anymore for HA

# This allows you to modify the amperage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
amperage_factor=1.0

# This allows you to modify the wattage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
watt_factor=1.0

so i think its not connecting to my inverter, what could i do?

in docker-compose logs voltronic-mqtt it says:

pi@raspberrypi:/opt/ha-inverter-mqtt-agent $ docker-compose logs voltronic-mqtt
Attaching to voltronic-mqtt
voltronic-mqtt    | Error: Connection refused
voltronic-mqtt    | Error: Connection refused

did you restart your pi? restart, wait a little bit for container to go up and then run again the command.
did you run my instructions with sudo in front?

Hi, I installed fresh raspbian lite os, docker, docker-compose, ha and mqtt. But when I run sudo docker-compose build I saw error, what do u think, can that is the problem? I have installed portainer too, and ha-inverter-mqtt-agent is unhealty and when open log error is “timeout: the monitored command dumped core”

Nope. It is not

Ok. My error is QMOD read timeout, so can I change QMOD value, “5” to “6” for example. And can that’s the problem?

hi, in my fork it is not need it. it will find by itself.
did you try what byte4geek do? to set the baudrate, see post 469.

Yes, I tryed to set baud rate before execute docker-compose build. But interesting is that when I tryed to increase qpiri and qpiws values with your values + 30-40 and I receive no timeout error I receive incorrect start/stop bytes.

Yes, every command with sudo. As far i can see in the ned-kelly version i could receive data from the inverter, in this fork i cant. It’s related to the fact the inverter is not properly recognized by the software? in your fork the current CRC is F8 54 in the ned kelly one is 49 C1, what does that mean? You think error “Connection refused” is related to the connection with inverter or something else?
Thanks again!