Universal Solar Inverter over Modbus RS485 / TCP custom_component (AlphaESS, Growatt, Sofar, SolaX, Solinteg, Solis, SRNE, Swatten, TIGO TSI & Qcells Q.Volt Hyb)

Hi. Hope this is the right place for advice.

I have an SK-SU5000E. No pocket wifi, just the inbuilt wifi AP and ethernet.

The standard Solax integration @squishykid maintains was working just fine until the wifi AP on my inverter stopped working. I can’t connect to the Solax_ AP despite using 7 different devices and turning of all other 2.4 wifi channels around.

I connected the inverter to my router via ethernet and reserved the IP address. It is sending my data to solax_portal.com so connection must be ok but not accessible on port 80 unlike the wifi AP.

solaxcloud.com won’t accept my wifi serial number so I can’t use the cloud api integration.

I’ve copied solax_modbus to custom_components.

Configuration > Integrations > +ADD INTEGRATION > SolaX Inverter Modbus
results in “Error: Config flow could not be loaded”. Trying to add another integration after results in “Please wait while the integration is being setup” forever until the client is killed or page reloaded.

So I added this to configuration.yaml

modbus:
  - type: tcp
    host: 192.168.4.104
    port: 502
    name: "SolaX"
sensor:
  - platform: modbus
    scan_interval: 1
    registers:
      - name: SolaX Inverter Voltage
        hub: SolaX
        unit_of_measurement: V
        register: 0
        register_type: input
        scale: 0.1
        precision: 1

In the log I get: 2021-10-20 09:18:49 WARNING (SyncWorker_0) [homeassistant.components.modbus.modbus] modbus SolaX communication open

and

File “/home/.homeassistant/custom_components/solax_modbus/init.py”, line 19, in

  • from .const import (*
  • File “/home/.homeassistant/custom_components/solax_modbus/const.py”, line 133, in *
  • SENSOR_TYPES: dict[str, list[SolaXModbusSensorEntityDescription]] = {*
    TypeError: ‘type’ object is not subscriptable

I also tried using the package solax_hybrid_g2_pylontech.yaml but it won’t pass giving:
Error loading /home/.homeassistant/configuration.yaml: while parsing a block mapping in “/home/.homeassistant/packages/solax_x1g2.yaml”, line 457, column 9 expected , but found ‘’ in “/home/.homeassistant/packages/solax_x1g2.yaml”, line 466, column 12

Advice appreciated.

thanks @wills106 for this integration. Very keen to get it going!

I own a X1-Boost/Air/Mini , tried various X1 inverters in the custom compontent integration but none of them work.

The log gives:
Reading data failed! Inverter is offline.

Also in the log:
Connection to (192.168.2.160, 502) failed: [Errno 111] Connection refused

Version 0.3.3

Added:

EPS Sensors:

  • EPS Auto Restart
  • EPS Min Esc SOC
  • EPS Min Esc Voltage

Gen 3 Sensors:

  • Backup Charge End
  • Backup Charge Start
  • Backup Gridcharge
  • Cloud Control (Disabled by default)
  • CT Meter Setting (Disabled by default)
  • Discharge Cut Off Capacity Grid Mode (Disabled by default)
  • Discharge Cut Off Point Different (Disabled by default)
  • Discharge Cut Off Voltage Grid Mode (Disabled by default)
  • Forcetime Period 1 Maximum Capacity
  • Forcetime Period 2 Maximum Capacity
  • Global MPPT Function (Disabled by default)
  • Machine Style (Disabled by default)
  • Meter 1 id (Disabled by default)
  • Meter 2 id (Disabled by default)
  • Meter Function (Disabled by default)
  • Power Control Timeout (Disabled by default)
  • wAS4777 Power Manager (Disabled by default)

Gen 3 X3 Sensors:

  • Earth Detect X3
  • Grid Service X3
  • Phase Power Balance X3

Number:

  • ForceTime Period 1 Max Capacity
  • ForceTime Period 2 Max Capacity

Also corrected “Select Naming” & Adjusted Gen2 rounding


For people who are having trouble I would first try removing the integration from the “Integrations Page” deleting the solax_modbus folder. Restarting Home Assistant, download the new version and start again from scratch.

You also can’t run the custom component and the “package” version at the same time.
You shouldn’t have any Modbus config in your configuration.yaml file or else were for Solax

If you get a connection refused you have tried to connect to the inverter twice at the same time. Normally the inverter will recover from this, but on the odd occasion you might need to power cycle the inverter to allow Modbus communications again.

Edit:
If the package versions no longer work there may have been a change to the built in Modbus Component. I am not keeping track of changes to the built in Modbus component and I recommend you use the custom_component as most functionality is there now and I will no longer be updating the packages.

1 Like

Thank you @wills106 for the update and guidance. Makes sense.

I removed modbus and anything solax from configuration.yaml.

I removed the solax_modbus directory and downloaded the new one to replace it. I couldn’t remove the integration from the integrations page as it never loaded. Restarted HA.

Configuration > Integrations > +ADD INTEGRATION > SolaX Inverter Modbus

Same result: Error “Config flow could not be loaded”

I never get the configuration dialogue box.

Log below:

This error originated from a custom integration.

Logger: aiohttp.server
Source: custom_components/solax_modbus/const.py:156 
Integration: SolaX Inverter Modbus (documentation, issues) 
First occurred: 9:52:05 PM (1 occurrences) 
Last logged: 9:52:05 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/components/http/forwarded.py", line 92, in forwarded_middleware
    return await handler(request)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
    return await handler(request)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/components/http/auth.py", line 144, in auth_middleware
    return await handler(request)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/components/config/config_entries.py", line 130, in post
    return await super().post(request)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/helpers/data_entry_flow.py", line 72, in post
    result = await self._flow_mgr.async_init(
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/data_entry_flow.py", line 151, in async_init
    flow, result = await task
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/data_entry_flow.py", line 169, in _async_init
    flow = await self.async_create_flow(handler, context=context, data=data)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/config_entries.py", line 709, in async_create_flow
    integration.get_platform("config_flow")
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/loader.py", line 532, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/loader.py", line 537, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/.homeassistant/custom_components/solax_modbus/__init__.py", line 19, in <module>
    from .const import (
  File "/home/.homeassistant/custom_components/solax_modbus/const.py", line 156, in <module>
    SENSOR_TYPES: dict[str, list[SolaXModbusSensorEntityDescription]] = {
TypeError: 'type' object is not subscriptable

Before adding the Integration in the Integration page have you tried to clear the browser cache or tried Ctrl+F5 on the Integration Page before trying to add it again? Assuming you are on a Windows machine.

1 Like

Just tried clearing browser cache on Mac (safari, chrome, Firefox) and on Linux HA server (Firefox). Unfortunately the same result with each “Error: config flow could not be loaded” and the same log file errors.

Apologies for being a problem child. Likely something I’ve done to stuff it up. I’d really love to get this going.

Thanks @wills106

I take it your HomeAssistant is a fairly recent version?

It seems like it doesn’t like SensorEntityDescription

Latest I think Will

System Health

version: core-2021.10.6
installation_type: Unknown
dev: false
hassio: false
docker: false
user: xx
virtualenv: false
python_version: 3.8.10
os_name: Linux
os_version: 5.11.0-38-generic
arch: x86_64
timezone: Australia/Brisbane


GitHub API: ok
Github API Calls Remaining: 4999
Installed Version: 1.15.2
Stage: running
Available Repositories: 949
Installed Repositories: 42


logged_in: true
subscription_expiration: November 15, 2021, 10:00 AM
relayer_connected: true
remote_enabled: true
remote_connected: true
alexa_enabled: true
google_enabled: true
remote_server: ap-southeast-1-0.ui.nabu.casa
can_reach_cert_server: ok
can_reach_cloud_auth: ok
can_reach_cloud: ok


dashboards: 1
resources: 29
views: 11
mode: storage

Yea, just wanted to double check it wasn’t really old and didn’t understand SensorEntityDescription

1 Like

I have the same problem here. I have everything working, but I cannot give commands to the inverter (write registers). Did you get to do it?

thanks a lot!

Thanks for all the work on this integration. I would very much like to use it, however I’m trying to connect a Solax X3 with RS485 connectivity. Is there any way on using this integration while using RS485 instead of Modbus over TCP?

You can use the Packages with RS485, but I don’t know if they work any more with the current built in Modbus setup?

But the custom_component only supports TCP at the moment, I haven’t looked into adding RS485 support directly yet.

You could look into using a Ethernet / WiFi to Modbus bridge? Like https://www.amazon.co.uk/dp/B07BC77L8K never used one personally.

Dear Will, I try to use your solax input parameters in an automation. Unfortunately I do not succeed in eg setting the value for select.solax_run_mode_select. If you used this already in an automation, can you please share ? Tx, Wim

Hi,

This is my automation to turn on/off force mode in the nights when the electricity is cheap. I dont use the new integration but the package files.

alias: Batteri force laddning
description: ''
trigger:
  - platform: time
    at: '02:00'
condition:
  - condition: state
    entity_id: input_boolean.forcerad_laddning
    state: 'on'
action:
  - service: automation.trigger
    data: {}
    entity_id: automation.solax_forcetime
  - delay:
      hours: 3
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: automation.trigger
    data: {}
    entity_id: automation.solax_forcetime_off
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.forcerad_laddning
mode: single

Hey tx for sharing your automation. Unfortunately I currently use the new component and not the package. Using them together is not possbible …

Great work on the custom component. I’ve been looking for a better way of viewing and monitoring my Solax inverter for a few months and this seems to be working great.

1 Like

I don’t have any proper Automations setup at the min, but I had a play with Services under Developer Tools and the following worked fine:

service: select.select_option
target:
  entity_id: select.solax_run_mode_select
data:
  option: Self Use Mode

So it should be very easy to put that inside an action:
Just change “Self Use Mode” to one of the 4 options listed on the states page.

I just wanted to feedback on this issue.

It was resolved by logging on to the web UI to control the inverter not the mobile app soon as I did that I was able to change modes… very strange!

Strange, you would think they worked in the same manner?

Dear wills106,

I have a X1 hybrid with a 6.3 battery, and have been using your component for some time now.
I noticed that the sensor for the house load (sensor.solax_house_load) only presents the correct value, when the is charge in the battery. If the battery is dead, the house load sensor has value = 0. See attached image. Any hints on this?