wills106 / homeassistant-solax-modbus

SolaX Power Modbus custom_component for Home Assistant (Supports some Ginlong Solis, Growatt, Sofar Solar, TIGO TSI & Qcells Q.Volt Hyb)
312 stars 96 forks source link

X3-MIC/PRO #88

Closed CristiXP closed 2 years ago

CristiXP commented 2 years ago

Does this integration work with the X3-MIC/PRO as I have installed it, and I get unknown everywhere. Any ideea how to fix this?

Thank you,

Cristian

wills106 commented 2 years ago

There are other X3 MIC / Pro MIC users, but no one has confirmed if it works or not.

Does your Inverter Serial Number start MC10 or MU80? If yours does start with one of them Serial Numbers then it confirms the serial Number is read at a different location to the other Inverters. So this Integration will require further work to support your Inverter.

wills106 commented 2 years ago

If your Inverter is a MC10 or MU80 can you try the built in Modbus component in HA and let me know if the below returns your Serial Number or not?

modbus:
  name: SolaX 
  type: serial # Comment out for Modbus over TCP
  method: rtu # Comment out for Modbus over TCP
  port: /dev/ttyUSB0 # Comment out for Modbus over TCP
  baudrate: 9600 # Comment out for Modbus over TCP
  stopbits: 1 # Comment out for Modbus over TCP
  bytesize: 8 # Comment out for Modbus over TCP
  parity: N # Comment out for Modbus over TCP

# Uncomment for Modbus over TCP
  # type: tcp
  # host: !secret inverter_ip
  # port: 502

  sensors:
  # Holding Registers
    - name: SolaX Serial Number
      address: 0x300
      count: 7
      data_type: string
      scan_interval: 5
CristiXP commented 2 years ago

Hello, thank you for the fast response. My inverter starts with this MP153TGAXXXXXX I have put this, but still shows unavailable :( I am available to test. The serial connection is working, as I have used it to retrieve data from the SDM630 meter. Now I am on pin 4 and pin 5 and try to get data from inverter, but with no luck. modbus:

Captură de ecran din 2022-07-24 la 10 32 07 Captură de ecran din 2022-07-24 la 10 32 20
wills106 commented 2 years ago

Can you try the following addresses as well?

address: 0

and

address: 768

Have you tried swapping pin 4 & 5 around?

CristiXP commented 2 years ago

When I am using modpoll with wires like this, I am getting the Illegal data address exception message. When I am swapping them i receive an Checksum error message... so I think this is the wrong way on the pins.

Tried with 0 and 768 on the adress in pin 4 and 5 and swapped... still nothing :(

wills106 commented 2 years ago

Do you have a full example of what you are sending to the Inverter with Modpoll?

wills106 commented 2 years ago

I get unknown everywhere. Any ideea how to fix this?

In your error log did you get: unrecognized inverter type - serial number : MP153TGAXXXXXX

Or any other errors?

CristiXP commented 2 years ago

This is what I am sending with modpoll /config/modpoll -m rtu -1 -a 1 -b 9600 -d 8 -p none -r 1 /dev/ttyUSB I am only getting that the serial number is unknown.

Captură de ecran din 2022-07-24 la 12 54 18

0

infradom commented 2 years ago

Are you sure the baudrate for your model is 9600?

CristiXP commented 2 years ago

Are you sure the baudrate for your model is 9600?

When trying other baud rate, I have a Reply timeout error. When going on 9600 I get an illegal data adress exception message. I succesfully comunicated with the Smart Metter Eastron SDM630V2, on 9600 but pin 7 and 8 with the same setup, just not with the inverter.

CristiXP commented 2 years ago

In this thread someone stated that has fixed this for solx modbus integration, and that the X3 PRO is different than others... but no ideea what needs to be done to fix this. https://gathering.tweakers.net/forum/list_messages/2104298

Also here, people are speaking about a pdf from solax that is totally different than what we have for the hybrids.

https://github.com/InfernoEmbedded/PowerScraper/pull/16

wills106 commented 2 years ago

The Modbus docs mention Baud: 9600 I take it you are using a USB - RS485 adaptor for now and not a RS485 - Waveshare?

modpoll -b 9600 -p none -m rtu -a 1 -r 769 -c 7 /dev/ttyUSB

Does that return anything?

Edit: Or try

modpoll -b 9600 -p none -m rtu -a 1 -t 1 -r 1025 -c 7 /dev/ttyUSB

CristiXP commented 2 years ago

The Modbus docs mention Baud: 9600 I take it you are using a USB - RS485 adaptor for now and not a RS485 - Waveshare?

modpoll -b 9600 -p none -m rtu -a 1 -r 769 -c 7 /dev/ttyUSB

Does that return anything?

Edit: Or try

modpoll -b 9600 -p none -m rtu -a 1 -t 1 -r 1025 -c 7 /dev/ttyUSB

Captură de ecran din 2022-07-24 la 13 14 48
CristiXP commented 2 years ago

1025 gives Illegal data address exception.

infradom commented 2 years ago

The Modbus docs mention Baud: 9600 I take it you are using a USB - RS485 adaptor for now and not a RS485 - Waveshare? modpoll -b 9600 -p none -m rtu -a 1 -r 769 -c 7 /dev/ttyUSB Does that return anything? Edit: Or try modpoll -b 9600 -p none -m rtu -a 1 -t 1 -r 1025 -c 7 /dev/ttyUSB

Captură de ecran din 2022-07-24 la 13 14 48

This anwer seems to be the correct serial numbeer MP15... converted decimal to ascii

CristiXP commented 2 years ago

I am trying address 0x301 right now... let me check

wills106 commented 2 years ago

Yea just need to work out why the second one doesn't work. Never used Modpoll before.

infradom commented 2 years ago

The received answer for 769 was correct : I decoded it to MP15 ...

CristiXP commented 2 years ago

Still unavailable for 0x301

wills106 commented 2 years ago

Well I don't think getting modpoll -b 9600 -p none -m rtu -a 1 -t 1 -r 1025 -c 7 /dev/ttyUSB to work doesn't matter.

We know the Serial is at 0x300 and the registers should be at 0x400.

So just need to make the Integration try to look for a serial at 0x300 if 0x0 returns blank.

wills106 commented 2 years ago

If you are using the built in Modbus try:

  sensors:
  # Holding Registers
    - name: SolaX Serial Number
      address: 769
      count: 7
      data_type: string
      scan_interval: 5
infradom commented 2 years ago

But in this case, the serial number seems to be at 0x301 (769 decimal) Am I missing something ?

wills106 commented 2 years ago

Modpoll starts at 1 PyModbus starts at 0

infradom commented 2 years ago

ok, thanks

wills106 commented 2 years ago

I have used a GUI based one on Windows and that starts at 1 which is annoying as you have to offset everything by +1

infradom commented 2 years ago

strange ...

infradom commented 2 years ago

Sorry I deleted your message by accident, wanted to delete mine

infradom commented 2 years ago

Maybe the stringlength is not 7 for this model which makes the checksum fail. If we read it as numbers with modpoll, it does not complain ...

CristiXP commented 2 years ago

image image

wills106 commented 2 years ago

I have not used the built in Modbus so maybe group reading has changed

infradom commented 2 years ago

What happens if you try with other stringlengths: 14, 6,7,8, 16, 18 ?

wills106 commented 2 years ago

Does the below return your PV1 and PV2 DC Voltages?

  sensors:
  # Holding Registers
    - name: SolaX PV1
      address: 0x400
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5
    - name: SolaX PV2
      address: 0x401
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5
wills106 commented 2 years ago

I also think HA Modbus starts at 0 so the following should return your Serial?

  sensors:
  # Holding Registers
    - name: SolaX Serial Number
      address: 768
      count: 7
      data_type: string
      scan_interval: 5

As long as it is 7 characters long?

CristiXP commented 2 years ago

Does the below return your PV1 and PV2 DC Voltages?

  sensors:
  # Holding Registers
    - name: SolaX PV1
      address: 0x400
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5
    - name: SolaX PV2
      address: 0x401
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5

both unavailable. Also when modpoll for 1024 and 1025 get Illegal address exception.

infradom commented 2 years ago

I also think HA Modbus starts at 0 so the following should return your Serial?

  sensors:
  # Holding Registers
    - name: SolaX Serial Number
      address: 768
      count: 7
      data_type: string
      scan_interval: 5

As long as it is 7 characters long?

7 characters or 7 words? Our serial numbers are normally 14 characters ... I am not sure how the standard modbus integration treats string lengths

wills106 commented 2 years ago

7 characters or 7 words? Our serial numbers are normally 14 characters ... I am not sure how the standard modbus integration treats string lengths

I'm getting myself confused! It's 14 Chars, but over 7 Registers. We only need to read the first couple of registers anyway.

wills106 commented 2 years ago

Does the below return your PV1 and PV2 DC Voltages?

  sensors:
  # Holding Registers
    - name: SolaX PV1
      address: 0x400
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5
    - name: SolaX PV2
      address: 0x401
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5

both unavailable. Also when modpoll for 1024 and 1025 get Illegal address exception.

Have you tried 1024 and 1025 with the Built in Modbus instead of the 0x400 and 0x401 they may have removed the ability to use Hex values?

CristiXP commented 2 years ago

Yes, 1024 and 1025 and 0x400 and 0x401, same story. Only thing which is giving data, is when modpoll 769

Captură de ecran din 2022-07-24 la 14 15 31 Captură de ecran din 2022-07-24 la 14 16 05

.

wills106 commented 2 years ago
  sensors:
  # Input Registers
    - name: SolaX Group i1
      address: 1024
      input_type: input
      count: 14
      data_type: custom
      structure: ">14H"
      scan_interval: 5

Does that return 14 sets of values comma separated?

infradom commented 2 years ago

7 characters or 7 words? Our serial numbers are normally 14 characters ... I am not sure how the standard modbus integration treats string lengths

I'm getting myself confused! It's 14 Chars, but over 7 Registers. We only need to read the first couple of registers anyway.

Indeed, but the modbus library we use might refuse the shorter substring because a CRC checksum is not correct anymore. Sorry I am following this discussion while doing other work, so it may not have my full attention ..

wills106 commented 2 years ago

For your SolaX Serial you need the count to be 7 not 14 assuming your serial is 14 chars long. If there is nothing after the 7th register like on the X1AC it will give an error.

CristiXP commented 2 years ago
  sensors:
  # Input Registers
    - name: SolaX Group i1
      address: 1024
      input_type: input
      count: 14
      data_type: custom
      structure: ">14H"
      scan_interval: 5

Does that return 14 sets of values comma separated?

it doesn't load the entity at all... Cannot find it. so something wrong in the syntax maybe

Captură de ecran din 2022-07-24 la 14 37 23

.

wills106 commented 2 years ago

When in the Developer Tools Page, if you press check configuration does it give any errors?

CristiXP commented 2 years ago

No errors. It was because I still had the PV1 on the same 1024 address

Captură de ecran din 2022-07-24 la 14 43 37 Captură de ecran din 2022-07-24 la 14 44 45
wills106 commented 2 years ago

Can your copy and paste your complete code for modbus. Don't forget to wrap the code with <>

Also do you still have an active session of Modpoll running at the same time as HA? It might be blocking the access.

CristiXP commented 2 years ago

I am using only your suggestions.

  - name: SolaX
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    port: /dev/ttyUSB0
    stopbits: 1

    sensors:

    - name: SolaX Serial Number
      address: 768
      count: 14
      data_type: string
      scan_interval: 5

    - name: SolaX Group i1
      address: 1025
      input_type: input
      count: 14
      data_type: custom
      structure: ">14H"
      scan_interval: 5

And this is an example of entity for the SDM630 smart metter that worked before:

- name: sdm630_phase_1_line_to_neutral_volts
        slave: 1
        address: 0
        input_type: input
        count: 2
        precision: 2
        data_type: float32
        unit_of_measurement: V
        device_class: voltage
        scan_interval: 60
wills106 commented 2 years ago

I have not used the built in one in ages. Does the following work?

  - name: SolaX
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    port: /dev/ttyUSB0
    stopbits: 1

    sensors:

    - name: SolaX Serial Number
      slave: 1
      address: 768
      count: 7
      data_type: string
      scan_interval: 5

    - name: SolaX Group i1
      slave: 1
      address: 1024
      input_type: input
      count: 14
      data_type: custom
      structure: ">14H"
      scan_interval: 5
CristiXP commented 2 years ago

I have not used the built in one in ages. Does the following work?

  - name: SolaX
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    port: /dev/ttyUSB0
    stopbits: 1

    sensors:

    - name: SolaX Serial Number
      slave: 1
      address: 768
      count: 7
      data_type: string
      scan_interval: 5

    - name: SolaX Group i1
      slave: 1
      address: 1024
      input_type: input
      count: 14
      data_type: custom
      structure: ">14H"
      scan_interval: 5

yes, this started showing up some info will check with 768.

CristiXP commented 2 years ago

For the serial number, it should read MP not PM... 15 not 51... it's backwards.

wills106 commented 2 years ago

Looks like the serial number is reversing each char set. If you add the following template do the values match your Inverter?

sensor:
- platform: template
  sensors:
# SolaX Group I1
    solax_pv_voltage_1:
      friendly_name: "SolaX PV Voltage 1"
      unit_of_measurement: V
      value_template: "{{ states('sensor.solax_group_i1').split(',')[0]| float / 10 }}"
    solax_pv_voltage_2:
      friendly_name: "SolaX PV Voltage 2"
      unit_of_measurement: V
      value_template: "{{ states('sensor.solax_group_i1').split(',')[1]| float / 10 }}"
    solax_pv_current_1:
      friendly_name: "SolaX PV Current 1"
      unit_of_measurement: A
      value_template: "{{ states('sensor.solax_group_i1').split(',')[2]| float / 10 }}"
    solax_pv_current_2:
      friendly_name: "SolaX PV Current 2"
      unit_of_measurement: A
      value_template: "{{ states('sensor.solax_group_i1').split(',')[3]| float / 10 }}"
    solax_inverter_temperature:
      friendly_name: "SolaX Inverter Temperature"
      unit_of_measurement: °C
      value_template: "{{ states('sensor.solax_group_i1').split(',')[13] }}"