wills106 / homeassistant-solax-modbus

SolaX Power Modbus custom_component for Home Assistant (Supports some AlphaESS, Growatt, Sofar, Solinteg, Solis, SRNE, Swatten)
317 stars 101 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

Also does this correct your Serial?

  - 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
      swap: byte
      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

Any ideea where should I add them exactly? This is from my config yaml.

CristiXP commented 2 years ago

Also does this correct your Serial?

  - 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
      swap: byte
      scan_interval: 5

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

Serial corrected.

wills106 commented 2 years ago

You shouldn't need to declare each one as a sensor, they should inherit the main sensor

template:
  - sensor:
    - name: energy_solax_today
      state: "{{ states('sensor.solax_today') }}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

    - name: energy_total
      state: "{{ states('sensor.solax_total') }}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

    - name: energy_consumed_energy
      state: "{{ states('sensor.consumed_energy') }}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

    - name: energy_feed_in_energy
      state: "{{ states('sensor.feed_in_energy') }}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

    - name: energy_car
      state: "{{ states('sensor.tesla_model_3_energy_added_sensor')}}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

    - name: 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 }}"

    - name: 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 }}"

    - name: 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 }}"

    - name: 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 }}"

    - name: solax_inverter_temperature:
      friendly_name: "SolaX Inverter Temperature"
      unit_of_measurement: °C
      value_template: "{{ states('sensor.solax_group_i1').split(',')[13] }}"
CristiXP commented 2 years ago

With the part of my template, it is working. But when I am adding your part, I am receiving an error:

template:
  - sensor:
    - name: energy_solax_today
      state: "{{ states('sensor.solax_today') }}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

    - name: energy_total
      state: "{{ states('sensor.solax_total') }}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

    - name: energy_consumed_energy
      state: "{{ states('sensor.consumed_energy') }}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

    - name: energy_feed_in_energy
      state: "{{ states('sensor.feed_in_energy') }}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

    - name: energy_car
      state: "{{ states('sensor.tesla_model_3_energy_added_sensor')}}" 
      unit_of_measurement: 'kWh'
      state_class: total_increasing
      device_class: energy

When I add this it brakes it

- name: 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 }}"
Captură de ecran din 2022-07-24 la 15 46 56

Took the : out, it says that code is ok... but when restarting it, the template brakes.

wills106 commented 2 years ago

Sorry remove the colon ( : ) at the end of each name.

- name: solax_pv_voltage_1: 
should be
- name: solax_pv_voltage_1

- name: solax_pv_voltage_2:
should be
- name: solax_pv_voltage_2

etc

CristiXP commented 2 years ago

Removed them already, but after restart it brakes the template

Captură de ecran din 2022-07-24 la 15 55 19 Captură de ecran din 2022-07-24 la 15 55 28 Captură de ecran din 2022-07-24 la 15 55 12

.

wills106 commented 2 years ago

You are using a very different config style to me, so I am finding it difficult to adapt my style to yours. Maybe you do need to declare each one of your template as a unique sensor?

Are you able to https://github.com/wills106/homeassistant-solax-modbus/releases/tag/X3-Mic_Test Does it report your Inverter as unknown and with the serial number the correct way round? It still wont give you any values, but at least it will confirm if it's reading the Serial correct.

Now I have confirmation that the serial is at 0x300 I am best working on updating the integration, yaml is too frustrating at times.

CristiXP commented 2 years ago

Updated the Solax Modbus integration from HACS right now. This is what I have in log

Captură de ecran din 2022-07-24 la 16 04 26 Captură de ecran din 2022-07-24 la 16 03 09

s

wills106 commented 2 years ago

If you change X3-Mic Test is should read correct.

CristiXP commented 2 years ago

Where I should change that? Or from where?

wills106 commented 2 years ago

Did you press update in HACS for SolaX Modbus and restart? If you have, remove the Integration from the Integration page and readd it. Hopefully when you look in the log it will give you the following: unrecognized inverter type - serial number : MP153TGAXXXXXX

CristiXP commented 2 years ago

Deleted the integration, restarted HA, installed again, restarted. Same issue.

Captură de ecran din 2022-07-24 la 16 17 47 Captură de ecran din 2022-07-24 la 16 20 05
wills106 commented 2 years ago

Do you still have the modbus config in your configuration.yaml? If so remove it all andy try again. You can only have a single connection to your Inverter.

wills106 commented 2 years ago

O wait, I have missed something out of the test file.

CristiXP commented 2 years ago

Took it out. Same thing

Captură de ecran din 2022-07-24 la 16 26 17
wills106 commented 2 years ago

Try "X3 Mic Test 2" when it shows up in HACS

CristiXP commented 2 years ago

It shows version 0.5.8 not Mic Test 2... installing right now.

wills106 commented 2 years ago

If you can't see the Mic Test 2, click on SolaX Modbus in hacs then the 3 dots at the top, then Redownload and select show Betas

CristiXP commented 2 years ago

I have downloaded the Mic Test 2

Captură de ecran din 2022-07-24 la 17 02 40

The modbus was taken out from my config file. Installing the integration, restarting HA and still shows unknown.

Captură de ecran din 2022-07-24 la 17 05 28
wills106 commented 2 years ago

Are there any other logs regarding SolaX?

CristiXP commented 2 years ago

These are the logs regarding solax

Captură de ecran din 2022-07-24 la 17 16 14

.

wills106 commented 2 years ago

That initial read for serial. What's the full error?

CristiXP commented 2 years ago
Captură de ecran din 2022-07-24 la 17 18 43
infradom commented 2 years ago

Sorry for coming with this remark so late: when using a RS485 to USB adapter the solax_modbus integraton only supports baudrate 19200 right now. People using other baudrates use a RS485 to Ethernet adapter. Can you modify the baudrate on the MIC to 19200 ?

wills106 commented 2 years ago

Ahh I forgot all about that!!! I'll change the Test Mic to v3 with the Baudrate hard coded. At least we can see if the Integration can read your serial or not.

CristiXP commented 2 years ago

Ahh I forgot all about that!!! I'll change the Test Mic to v3 with the Baudrate hard coded. At least we can see if the Integration can read your serial or not.

This is what I tested manually till now...

Captură de ecran din 2022-07-24 la 17 44 34
infradom commented 2 years ago

we could add an optioan config parameter for baudrate, but I prefer people use a waveshare like Ethernet adapter (due to the other warning and the relatively low cost)

wills106 commented 2 years ago

@CristiXP Can you see if X3 Mic Test3a will give you your Serial number in the logs?

wills106 commented 2 years ago

I agree Waveshare seems a much better option.

wills106 commented 2 years ago

We are getting somewhere now, not sure why they have decided to reverse the byte order on the X3 Mic?

infradom commented 2 years ago

I believe that was not needed, and the normal version should do fine if you add MP* to the configs We got confused with the modpoll tool that required the byte swap

wills106 commented 2 years ago

I haven't byte swapped the X3 Mic Test3a, that's how the Inverter has responded.

All I changed was the Baud rate and the address from 0x0 to 0x300

CristiXP commented 2 years ago

If I am doing it like this, I have retrieved this data: Onlye by adding slave: 1 to your sensors. Probably the temp is not 230 degrees... and needs adjustment or not sure that 1028 is actually temp. The rest of the values, are correct.

modbus:

  - 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
      swap: byte
      scan_interval: 5

    - name: SolaX PV1
      slave: 1
      address: 1024
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5
    - name: SolaX PV2
      slave: 1
      address: 1025
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5
    - name: SolaX Amps PV1
      slave: 1
      address: 1026
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5
    - name: SolaX Amps PV2
      slave: 1
      address: 1027
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5
    - name: SolaX Inverter Temp
      slave: 1
      address: 1028
      input_type: input
      count: 1
      data_type: uint16
      scale: 0.1
      scan_interval: 5

image

infradom commented 2 years ago

I haven't byte swapped the X3 Mic Test3a, that's how the Inverter has responded.

All I changed was the Baud rate and the address from 0x0 to 0x300

Ok, sorry , I did not follow the discussion with much attention as I was concentrating on another project

wills106 commented 2 years ago

Temp is 1037 not 1028, I skipped some registers out on that Template sensor that split the group read.

CristiXP commented 2 years ago

1028 is probabbly the PV1 Power W with diff scale.

wills106 commented 2 years ago

1028 is meant to be grid voltage, but scaled by 0.1 so I doubt your grid voltage is 23.3v

Does PV1 voltage and PV2 voltage match what you expect?

1044 and 1045 are your PV1 & 2 W doe they match up with the LCD on your Inverter?

You might find all of it needs byte swapping!

CristiXP commented 2 years ago

1028 was showing 233 with a scale of 0.1, so it's correct then for grid voltage. Restarting right now and let you know. Everything is correct. 1028/1029/1030 are values for R,S,T phase current.

1044/1045 also show correct values.

CristiXP commented 2 years ago

image

wills106 commented 2 years ago

Ok so it must just be the Serial that's Byte Swapped then.

I need to finish off support for Dry Contact on the Gen4 Hybrid then I can start looking into properly supporting the X3 Mic in the Integration, as the search for a Serial number will need modifying.

We will need an "if statement" that if it can't find a serial at 0x0 look for one at 0x300

Then it needs to read all of the sensors in a different location to the other SolaX inverters.

CristiXP commented 2 years ago

Till then, can you please provide me a list of all the adresses, so I can add them manually? Thank you.

wills106 commented 2 years ago

I promised I wouldn't share any documentation. But you can fill in the blanks with this:

Pv1 input voltage 0.1V Pv2 input voltage 0.1V Pv1 input current 0.1A Pv2 input current 0.1A R phase grid voltage 0.1V S phase grid voltage 0.1V T phase grid voltage 0.1V R phase grid frequency 0.01Hz S phase grid frequency 0.01Hz T phase grid frequency 0.01Hz R phase output current 0.1A S phase output current 0.1A T phase output current 0.1A Temperature 1°C Output power 1W Inverter status R phase output power 1W S phase output power 1W T phase output power 1W Total power of dc1 and dc2 1W Power of Dc1 1W Power of Dc2 1W

CristiXP commented 2 years ago

It's enough for me. For 1043, it is showing 0. Is there another address for Total power?

wills106 commented 2 years ago

It's meant to be that one. No saying it actually works or not? The docs are not always accurate.

None of the other Inverters actually have that register. I have to basically do a template sensor within the integration to combine PV1 Power & PV2 Power together.

CristiXP commented 2 years ago

No problem. All is working fine. Thank you for your support! Hopefully you will manage to update and correct the integration.

Thanks alot!!!

wills106 commented 2 years ago

@infradom Is this correct https://github.com/wills106/homeassistant-solax-modbus/blob/d8642af5cb59c993b3709ddc06d121b6cbe83f51/custom_components/solax_modbus/const.py#L50

Or should it be be a different Value?

CristiXP commented 2 years ago

Does it have any address for the feedin power to the grid or taking from the grid? Or the actual house consumption? Or those are taken from the smart metter and not exposed? Or calculated form Output and Total power? image

CristiXP commented 2 years ago

No adress is measuring kWh? There are missing feedin energy,consumed energy, energy today and energy total.

wills106 commented 2 years ago

On the Hybrids there is a calculation within the Integration:

if   feedin_power > 0: self.data["grid_export"] = feedin_power
else: self.data["grid_export"] = 0
if   feedin_power < 0: self.data["grid_import"] = abs(feedin_power)
else: self.data["grid_import"] = 0 
self.data["house_load"] = inverter_load - feedin_power

Does your Output Power match either 683w or 771w in your picture?