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)
288 stars 85 forks source link

[Bug]: Solax EV Charger not working values #805

Open Philipp-X1 opened 4 months ago

Philipp-X1 commented 4 months ago

Describe the bug

As mentioned here https://github.com/wills106/homeassistant-solax-modbus/pull/772 I want to report not working values related to the EV Charger

Integration Version

2024.03.01

Homeassistant core version

2024.3.0

Inverter brand

Solax X3-EVC-11K

Plugin used

plugin_solax_ev_charger.py

Serial prefix

C31103

Inverter firmware versions

N/A

Connection Method

Waveshare RS485 to ETH

Dongle firmware

N/A

Detailed Error Log

The Entity name = "Charge Added Total" shows 111.457.075,2 kWh at my charger but should be 1.700,7 kWh

Most other entities seem to be ok. I think we wont see any Grid related values ever because there cant be any data source for them ( No CT Clamps and no connection to Inverter...)?!

Furthermore i can only check the values for 1 Phase since my Car only supports 1 Phase charging. But maybe there will be a user in the near future to check them out.

Bigger problem seems to be that I cant restart charging after I put the charger use mode to "stop" while I am charging. So if I want to go back to Fast Eco or Green nothing is happening. When I am using the homeassistant-solax-http plugin I can start the charing again. Maybe @PatrikTrestik could take a look at this somewhen :)

Thanks!

Additional context

No response

PatrikTrestik commented 4 months ago

Seems related to REG32 value parsing. I'll try to fix, but have to find time to "rewire" my garage for it. Possibly next week.

PatrikTrestik commented 3 months ago

Solved in https://github.com/wills106/homeassistant-solax-modbus/pull/829

Philipp-X1 commented 3 months ago

Sorry. My fault mixing this up.

The question that should be posted here:

Could you also take a look at the Start Stop issue? If you change the Charger to Stop in HA it is inpossible to change to Fast Green or Eco anymore. Thank you :)

johny-mnemonic commented 3 months ago

Starting the charging also doesn't work for me through Modbus.

Also I am not sure what was the root cause, but since I added the EVC as a second device to the modbus integration my Inverter started behaving really weird. It was randomly charging and discharging the battery with high power (like 8-10kW !!!) and then I noticed it also reports really high consumption and even production of the house. It was showing peaks more than 10-12kW of consumption and up to 8kW production, while there is nothing in my house which could produce any electricity.

HA_solax_modbus_1

I tried to turn OFF/ON the inverter thinking something got it confused, but in the end what helped was to just delete the EVC from the modbus integration, after which everything got back to normal. Here are the interesting logs before I deleted the EVC:

2024-04-04 13:48:08.306 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x48: grid_export_total
2024-04-04 13:48:08.306 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x4a: grid_import_total
2024-04-04 13:48:08.306 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x50: today_yield
2024-04-04 13:48:08.306 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x52: total_yield
2024-04-04 13:48:08.306 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x54: lock_state
2024-04-04 13:48:09.043 ERROR (MainThread) [custom_components.solax_modbus] Something went wrong reading from modbus
Traceback (most recent call last):
  File "/config/custom_components/solax_modbus/__init__.py", line 614, in async_read_modbus_data
    res = await self.async_read_modbus_registers_all()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solax_modbus/__init__.py", line 790, in async_read_modbus_registers_all
    self.data[descr.key] = descr.value_function(0, descr, self.data)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solax_modbus/const.py", line 232, in value_function_grid_export
    if val>0: return val
       ^^^^^
TypeError: '>' not supported between instances of 'NoneType' and 'int'
2024-04-04 14:03:38.962 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0xcc: grid_voltage_meter_l3
2024-04-04 14:03:38.963 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x100: modbus_power_control
2024-04-04 14:03:38.963 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x101: target_finish_flag
2024-04-04 14:03:38.963 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x102: active_power_target
2024-04-04 14:03:38.963 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x104: reactive_power_target
2024-04-04 14:03:38.963 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x106: active_power_real
2024-04-04 14:03:38.964 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x108: reactive_power_real
2024-04-04 14:03:38.964 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x10a: active_power_upper
2024-04-04 14:03:38.964 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x10c: active_power_lower
2024-04-04 14:03:38.964 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x10e: reactive_power_upper
2024-04-04 14:03:38.964 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x110: reactive_power_lower
2024-04-04 14:03:38.964 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x114: charge_discharge_power
2024-04-04 14:03:38.964 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x116: chargeable_battery_capacity
2024-04-04 14:03:38.964 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x118: remaining_battery_capacity
2024-04-04 14:11:09.171 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0xcc: grid_voltage_meter_l3
2024-04-04 14:11:09.172 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x100: modbus_power_control
2024-04-04 14:11:09.172 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x101: target_finish_flag
2024-04-04 14:11:09.172 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x102: active_power_target
2024-04-04 14:11:09.172 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x104: reactive_power_target
2024-04-04 14:11:09.173 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x106: active_power_real
2024-04-04 14:11:09.173 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x108: reactive_power_real
2024-04-04 14:11:09.173 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x10a: active_power_upper
2024-04-04 14:11:09.173 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x10c: active_power_lower
2024-04-04 14:11:09.173 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x10e: reactive_power_upper
2024-04-04 14:11:09.173 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x110: reactive_power_lower
2024-04-04 14:11:09.173 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x114: charge_discharge_power
2024-04-04 14:11:09.174 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x116: chargeable_battery_capacity
2024-04-04 14:11:09.174 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x118: remaining_battery_capacity
2024-04-04 14:15:39.011 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0xcc: grid_voltage_meter_l3
2024-04-04 14:15:39.012 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x100: modbus_power_control
2024-04-04 14:15:39.012 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x101: target_finish_flag
2024-04-04 14:15:39.012 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x102: active_power_target
2024-04-04 14:15:39.012 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x104: reactive_power_target
2024-04-04 14:15:39.013 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x106: active_power_real
2024-04-04 14:15:39.013 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x108: reactive_power_real
2024-04-04 14:15:39.013 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x10a: active_power_upper
2024-04-04 14:15:39.013 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x10c: active_power_lower
2024-04-04 14:15:39.013 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x10e: reactive_power_upper
2024-04-04 14:15:39.014 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x110: reactive_power_lower
2024-04-04 14:15:39.014 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x114: charge_discharge_power
2024-04-04 14:15:39.014 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x116: chargeable_battery_capacity
2024-04-04 14:15:39.014 WARNING (MainThread) [custom_components.solax_modbus] SolaX: read failed at 0x118: remaining_battery_capacity

Looks like generic issue with the modbus communication to me. I am using Waveshare RTU to TCP converter for the communication with the Inverter and EVC and there is also modbus link on another wire pair in that UTP cable which is used by Inverter to read data from Smart Meter. Hard to say what was wrong, but it looks almost as if the inverter had hard time reading the data from the Smart Meter and reporting wrong readings. Could it be there was too much modbus communication in that cable?

Philipp-X1 commented 3 months ago

Looks like generic issue with the modbus communication to me. I am using Waveshare RTU to TCP converter for the communication with the Inverter and EVC and there is also modbus link on another wire pair in that UTP cable which is used by Inverter to read data from Smart Meter. Hard to say what was wrong, but it looks almost as if the inverter had hard time reading the data from the Smart Meter and reporting wrong readings. Could it be there was too much modbus communication in that cable?

Are you trying to daisy chain? This is as far as I know not working. I am using one Adater for the Inverter And another Adapter only for the EV Charger.

PatrikTrestik commented 3 months ago

Starting the charging also doesn't work for me through Modbus.

Also I am not sure what was the root cause, but since I added the EVC as a second device to the modbus integration my Inverter started behaving really weird. It was randomly charging and discharging the battery with high power (like 8-10kW !!!) and then I noticed it also reports really high consumption and even production of the house. It was showing peaks more than 10-12kW of consumption and up to 8kW production, while there is nothing in my house which could produce any electricity.

Looks like generic issue with the modbus communication to me. I am using Waveshare RTU to TCP converter for the communication with the Inverter and EVC and there is also modbus link on another wire pair in that UTP cable which is used by Inverter to read data from Smart Meter. Hard to say what was wrong, but it looks almost as if the inverter had hard time reading the data from the Smart Meter and reporting wrong readings. Could it be there was too much modbus communication in that cable?

Please, read about Modbus wiring and communication protocol. You can even destroy your hardware with incorrect wiring.

Modbus is single master bus where you could not just connect something. I have plan to write some page about connection options for SolaX inverter modbus, but for now you should know that it is not as simple and that daisy chain is also not simple.

Please start another Issue, because this is about fixing EVC modbus integration.

johny-mnemonic commented 3 months ago

I would be first to admit I might have done something wrong, but according to what I know I should have the cabling connected correctly now. It goes from Waveshare converter to inverter and from there to the EVC and the only master on the bus is the Waveshare converter. Inverter has address 1 and EVC 70 and when I connect from PC/HA to each of them by Modbus they seem to respond correctly. Another twisted pair in that same UTP cable is used for the second modbus link which goes from another port on the Inverter to the Smart Meter. Till I added EVC to the modbus integration in HA everything was working fine and is working fine since I removed it. So I suspect that the issue is more probably caused by the modbus integration which is trying to for example send commands to both EVC and Inverter at the same time probably causing collisions on the bus. This would be even expected to some degree, but what is definitely unexpected that it seems to somehow affect the communication running on the different twisted pair in the same UTP cable.

@PatrikTrestik In case you think this is caused by the modbus integration not using the single modbus link correctly for communicating with two or more devices, I will open separate issue for it. I was mainly posting it here as I was unsure what was going on and whether it could be me doing something wrong.

PatrikTrestik commented 3 months ago

I would be first to admit I might have done something wrong, but according to what I know I should have the cabling connected correctly now. It goes from Waveshare converter to inverter and from there to the EVC and the only master on the bus is the Waveshare converter. Inverter has address 1 and EVC 70 and when I connect from PC/HA to each of them by Modbus they seem to respond correctly. Another twisted pair in that same UTP cable is used for the second modbus link which goes from another port on the Inverter to the Smart Meter. Till I added EVC to the modbus integration in HA everything was working fine and is working fine since I removed it. So I suspect that the issue is more probably caused by the modbus integration which is trying to for example send commands to both EVC and Inverter at the same time probably causing collisions on the bus. This would be even expected to some degree, but what is definitely unexpected that it seems to somehow affect the communication running on the different twisted pair in the same UTP cable.

@PatrikTrestik In case you think this is caused by the modbus integration not using the single modbus link correctly for communicating with two or more devices, I will open separate issue for it. I was mainly posting it here as I was unsure what was going on and whether it could be me doing something wrong.

From you description it looks like you have all wired correctly. One more think to check is Waveshare setting Multihost. It should be in Multihost for sure even if you have only HA on TCP side. Second more important is baud rate. You should set Waveshare and Inverter to 9600 because EVC talks this.

Your wiring is correct so you should search on TCP side.

johny-mnemonic commented 3 months ago

Yep, I have baud rate set to 9600 and Multihost enabled with these params:

Instruction Time out: 1056
RS485 Conflict Time Gap: 164

I have been tuning these params when I had two clients on TCP side (HA and Loxone), but I have moved Loxone to use the WiFi dongle on the inverter so multiple clients should not be the source of trouble. It is possible that these params are causing some issues and it would be possible to tune it to behave better, but I am more concerned by the fact that the Invertor obviously had trouble communicating with the Smart Meter = the second modbus link was somehow affected by the link which is connected to the Waveshare.

Also not sure if there were some modbus issues introduced by recent changes in the integration or whether it is caused by switching to lower baudrate = lower bandwidth, but I can see small amount of errors in the log even now when there is only inverter connected.

Logger: custom_components.solax_modbus
Zdroj: custom_components/solax_modbus/__init__.py:614
integrace: SolaX Inverter Modbus (dokumentace, problémy)
První výskyt: 19:04:15 (1 výskyty)
Naposledy logováno: 19:04:15

Something went wrong reading from modbus
Traceback (most recent call last):
  File "/config/custom_components/solax_modbus/__init__.py", line 614, in async_read_modbus_data
    res = await self.async_read_modbus_registers_all()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solax_modbus/__init__.py", line 790, in async_read_modbus_registers_all
    self.data[descr.key] = descr.value_function(0, descr, self.data)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solax_modbus/const.py", line 232, in value_function_grid_export
    if val>0: return val
       ^^^^^
TypeError: '>' not supported between instances of 'NoneType' and 'int'

or

Logger: custom_components.solax_modbus
Zdroj: custom_components/solax_modbus/__init__.py:662
integrace: SolaX Inverter Modbus (dokumentace, problémy)
První výskyt: 18:29:44 (75 výskyty)
Naposledy logováno: 19:04:14

SolaX: read failed at 0x48: grid_export_total
SolaX: read failed at 0x4a: grid_import_total
SolaX: read failed at 0x50: today_yield
SolaX: read failed at 0x52: total_yield
SolaX: read failed at 0x54: lock_state

I am pretty sure I have first seen these kind of issues just during the last month. Either some logging was added or something started to work differently.

Anyway, this is off topic here. This issue is about finding why it is not possible to start charging using the modbus integration and we can move with the problems with modbus communication or multiple modbus devices to separate issue.

Philipp-X1 commented 2 months ago

Regarding that Start/Stop issue with modbus.

I could get in contact with Solax support and they tried to help me.

I was asking them why I can’t go back to Fast after I select Stop by using register = 0x60D.

So this is the answer:

Thank you very much for your patience. I just got a reply from our engineer. Your charger version needs to be updated to the latest. After that, set the 0x0627 4:Start charging before change the mode from 'stop' to other mode. It should work.

So I would like to ask if it is possible to make 0x0627 available in HA to test this?

IMG_2977

what do you think @PatrikTrestik ?

Oh and by the way the latest charger Firmware is 1.13

Philipp-X1 commented 2 months ago

I was taking a look at the plugin_solax_ev_charger.py I saw that control_command was already there just commented out. I removed the # and got it running.

It seems like it is working like Solax support told me.

Screenshot 2024-04-23 152655

And it seems like this is even supposed to start the charing process. You dont even need to change "Charger Use Mode"

After you select "Start Charging" in Control Command the EV Charger will start charging in the last known Use Mode. For Example after you stop in Green Mode, and start again by Control Command it will start in Green Mode. After you stop in Fast it will Start in Fast and so on...

Patrik could you remove the # for Control Command so that everyone can use it after next update please?

Thank you!

PatrikTrestik commented 2 months ago

It was commented, because it is not tested. Please run through all functions and options. Than if you confirm that everything works it is simple change to uncomment.

matomatusov commented 2 months ago

@Philipp-X1

Are you trying to daisy chain? This is as far as I know not working.
I am using one Adater for the Inverter
And another Adapter only for the EV Charger.

How do you have the EV charger connected? To make modbus TCP work on the EV charger? Thanks

Philipp-X1 commented 2 months ago

I have RS485 To RJ45 Ethernet, TCP/IP To Serial Adapter/Converter. If you want to know it exactly, this one. ( There are many others out there )

Connection to Inverter is disconnected. Only converter on the RS485 port of the Charger.

Philipp-X1 commented 2 months ago

Please run through all functions and options.

I went through all 6 functions. After seeing that nothing happens in: 1: "Available", 2: "Unavailable", 5: "Reserve", 6: "Cancel the Reservation"

I got in contact with Solax Support again asking which functions are behind those options and this is the answer: Thank you for your patience. Currently, write operations are only open for 3 and 4, start and stop. A read operation is just a return to a write operation. What you wrote is what you read back.

So it seems like we would just need 3: "Stop charging", 4: "Start Charging", at the moment.

I tested it while charging and it works. If you select "Stop charging" charger Stops and goes to charger use mode "Stop". After you select "Start Charging" it starts charging and goes to the last operated use mode "Eco" "Green" or "Fast"

So from my point of view this works fine.

Philipp-X1 commented 3 weeks ago

@PatrikTrestik do you think we can uncomment 0x0627 Control Command? As I already wrote it is working. It should be functional with Firmware 1.12 at least

Thank you

PatrikTrestik commented 3 weeks ago

@PatrikTrestik do you think we can uncomment 0x0627 Control Command? As I already wrote it is working. It should be functional with Firmware 1.12 at least

Thank you

Sure. I'll do it in next release.

Philipp-X1 commented 3 weeks ago

I have one question regarding the EV Charger Modbus Integration. I dont know if someone can take a look at this. I am getting a Logbook entry every 10 seconds about the RTC. ( 10 sec is my reading intervall of the integration ) So every 10 seconds it Logs the Date and Time. Is this behavior wanted?

PatrikTrestik commented 3 weeks ago

I have one question regarding the EV Charger Modbus Integration. I dont know if someone can take a look at this. I am getting a Logbook entry every 10 seconds about the RTC. ( 10 sec is my reading intervall of the integration ) So every 10 seconds it Logs the Date and Time. Is this behavior wanted?

Probably forgotten log. Create new issue and tag me, I'll look on it at Sunday.

Philipp-X1 commented 1 week ago

I have one question regarding the EV Charger Modbus Integration. I dont know if someone can take a look at this. I am getting a Logbook entry every 10 seconds about the RTC. ( 10 sec is my reading intervall of the integration ) So every 10 seconds it Logs the Date and Time. Is this behavior wanted?

Probably forgotten log. Create new issue and tag me, I'll look on it at Sunday.

done. https://github.com/wills106/homeassistant-solax-modbus/issues/950

Philipp-X1 commented 1 week ago

@PatrikTrestik do you think we can uncomment 0x0627 Control Command? As I already wrote it is working. It should be functional with Firmware 1.12 at least Thank you

Sure. I'll do it in next release.

could you take a look into this as well? After it i could finally close this issue :)