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,

I just plugged an USB cable into the inverter and my RaspberryPi running debian.
Ubuntu is a debian derivate and this python code should run on your laptop too.

import time

import hidapi as hid


def communicate_with_hid_device(vendor_id, product_id, command_str):
    try:
        device = hid.Device(vendor_id=vendor_id, product_id=product_id)
        print("Device opened.")
        device.nonblocking = True

        command_bytes = command_str.encode('ascii')
        device.write(command_bytes)
        print(f"command sent: {command_bytes}")

        time.sleep(1)
        response = device.read(64)
        if response:
            print(f"Response: {bytes(response).decode(errors='ignore')}")
        else:
            print("Got no response")

        device.close()

    except Exception as e:
        print(f"Fehler bei der HID-Kommunikation: {e}")

if __name__ == "__main__":
    vendor_id = 0x0665  # Cypress Semiconductor
    product_id = 0x5161  # USB to Serial
    command = "QPIGS\r"  # Beispielbefehl als String

    communicate_with_hid_device(vendor_id, product_id, command)

This is just a test script.

Hope it will help.

Ciao
bama

1 Like

Hi,
I’m using an Voltronic (EASUN branded) since 12 months. And it is the second USB serial device that is been killed by it … Suddenly, I don’t receive any data on the voltronic-mqtt container, and when I plug the USB serial device into my computer, it isn’t detected anymore …

Has anyone experencied such a problem?

Dear Joubert,
I connected an ESP8266 connected to the serial (RS232 cable) of an EASUN 8kW Hybrid Inverter and I read correctly the inverter status parameters.

To setup pipsolar current_max_ac_charging_current I adapted your suggested approach and code (see my code).

Now it happens that only in some cases of selected helper values ​​the current_max_ac_charging_current
is recorded in the inverter, in other cases a very different value is transmitted and since it does not belong to the set of allowed values, it is not recorded. Here is the list:

Helper: 2, 10, 20, 30, 40,50, 60, 70,80, 90,100,110,120 Amps
Registration: 153,218,139,188,185,56,103,152,12,131,100,110,120 Amps

Note that only in the cases of setup higher than 100: 100A, 110A, 120A the values ​​are registered in the inverter.

Can You help me ?

Here is the Logs of unsuccessful & successful registration:

[14:00:00][D][main:238]: STARTING VARIABLE ACCurrent
[14:00:00][D][pipsolar.output:015]: Will write: MUCHGC020 out of value 20.000000 / 20
[14:00:00][D][pipsolar:860]: got command: MUCHGC020
[14:00:00][D][pipsolar:851]: Command queued successfully: MUCHGC020 with length 9 at position 0
[14:00:00][D][main:063]: VARIABLE ACCurrent ENDS
[14:00:00][D][uart_debug:158]: >>> “MUCHGC020\xF3\xF1\r”
[14:00:00][D][pipsolar:811]: Sending command from queue: MUCHGC020 with length 9
[14:00:00][W][component:237]: Component esphome.coroutine took a long time for an operation (66 ms).
[14:00:00][W][component:238]: Components should block for at most 30 ms.
[14:00:00][D][uart_debug:158]: <<< “(NAKss\r”
[14:00:00][D][pipsolar:043]: response length for command OK
[14:00:00][D][pipsolar:776]: checking crc on incoming message
[14:00:00][D][pipsolar:779]: CRC OK
[14:00:00][D][pipsolar:049]: command not successful

[14:25:47][D][main:238]: STARTING VARIABLE ACCurrent
[14:25:47][D][pipsolar.output:015]: Will write: MUCHGC0100 out of value 100.000000 / 100
[14:25:47][D][pipsolar:860]: got command: MUCHGC0100
[14:25:47][D][pipsolar:851]: Command queued successfully: MUCHGC0100 with length 10 at position 1
[14:25:47][D][main:063]: VARIABLE ACCurrent ENDS
[14:25:47][D][uart_debug:158]: >>> “MUCHGC0100A\r”
[14:25:47][D][pipsolar:811]: Sending command from queue: MUCHGC0100 with length 10
[14:25:47][W][component:237]: Component esphome.coroutine took a long time for an operation (70 ms).
[14:25:47][W][component:238]: Components should block for at most 30 ms.
[14:25:47][D][uart_debug:158]: <<< “(ACK9 \r”
[14:25:47][D][pipsolar:043]: response length for command OK
[14:25:47][D][pipsolar:776]: checking crc on incoming message
[14:25:47][D][pipsolar:779]: CRC OK
[14:25:47][D][pipsolar:047]: command successful

[14:25:56][D][main:238]: STARTING VARIABLE ACCurrent
[14:25:56][D][pipsolar.output:015]: Will write: MUCHGC010 out of value 10.000000 / 10
[14:25:56][D][pipsolar:860]: got command: MUCHGC010
[14:25:56][D][pipsolar:851]: Command queued successfully: MUCHGC010 with length 9 at position 2
[14:25:56][D][main:063]: VARIABLE ACCurrent ENDS
[14:25:56][D][pipsolar:776]: checking crc on incoming message
[14:25:56][D][pipsolar:779]: CRC OK
[14:25:56][D][pipsolar:483]: Decode QFLAG
[14:25:56][D][uart_debug:158]: >>> “MUCHGC010\xA6\xA2\r”
[14:25:56][D][pipsolar:811]: Sending command from queue: MUCHGC010 with length 9
[14:25:56][W][component:237]: Component esphome.coroutine took a long time for an operation (64 ms).
[14:25:56][W][component:238]: Components should block for at most 30 ms.
[14:25:57][D][uart_debug:158]: <<< “(NAKss\r”
[14:25:57][D][pipsolar:043]: response length for command OK
[14:25:57][D][pipsolar:776]: checking crc on incoming message
[14:25:57][D][pipsolar:779]: CRC OK
[14:25:57][D][pipsolar:049]: command not successful

================================

Here is a fragment of ESPHOME code:
</>
api:
services:
- service: ac_grid_current
variables:
ACCurent: float
then:
- logger.log: “STARTING VARIABLE ACCurrent”
- output.pipsolar.set_level:
id: pipsolar_current_max_ac_charging_current
value: !lambda ‘return ACCurent;’
- logger.log: “VARIABLE ACCurrent ENDS”
output:

  • platform: pipsolar
    pipsolar_id: inverter0
    current_max_ac_charging_current:
    possible_values:
    • 2
    • 10
    • 20
    • 30
    • 40
    • 50
    • 60
    • 70
    • 80
    • 90
    • 100
    • 110
    • 120
      id: pipsolar_current_max_ac_charging_current
      </>
      ================================
      Here is the AUTOMATION:
      </>
  • id: ‘162702835999’
    alias: inverter Setting max charging Current
    description: ‘’
    trigger:
    • platform: state
      entity_id: input_select.setting_max_charging_current
      condition:
      action:
    • service: esphome.pipsolar_ac_grid_current
      data:
      ACCurent: “{% if is_state("input_select.setting_max_charging_current", "
      2 Amp") %}\n 2 \n{% elif is_state("input_select.setting_max_charging_current"
      , "10 Amp") %}\n 10 \n{% elif is_state("input_select.setting_max_charging_current"
      , "20 Amp") %}\n 20 \n{% elif is_state("input_select.setting_max_charging_current"
      , "30 Amp") %}\n 30 \n{% elif is_state("input_select.setting_max_charging_current"
      , "40 Amp") %}\n 40 \n{% elif is_state("input_select.setting_max_charging_current"
      , "50 Amp") %}\n 50 \n{% elif is_state("input_select.setting_max_charging_current"
      , "60 Amp") %}\n 60 \n{% elif is_state("input_select.setting_max_charging_current"
      , "70 Amp") %}\n 70 \n{% elif is_state("input_select.setting_max_charging_current"
      , "80 Amp") %}\n 80 \n{% elif is_state("input_select.setting_max_charging_current"
      , "90 Amp") %}\n 90 \n{% elif is_state("input_select.setting_max_charging_current"
      , "100 Amp") %}\n 100 \n{% elif is_state("input_select.setting_max_charging_current"
      , "110 Amp") %}\n 110 \n{% elif is_state("input_select.setting_max_charging_current"
      , "120 Amp") %}\n 120 \n{% endif %}\n”
      mode: single
      </>
      ================================

And the Helper:
input_select.setting_max_charging_current with the values of
2 Amp, 10 Amp, 20 Amp, 30 Amp,40 Amp,50 Amp,60 Amp,70 Amp,80 Amp,90 Amp,100 Amp,1100 Amp,120 Amp

Yes, me too.
yes I also have an EASUN hybrid inverter with a broken USB type C port. However I use the RS232 serial port connected to a RS232-TTL adapter (10 pieces for €12) + a few € ESP8266 which gives me Wifi connection.
Not using mqtt but ESPHOME from HA.

1 Like

Nice !
Can you please share your ESPHOME config and RS232-TTL to ESP8266 pinout?