Custom Component: ABB/Power-One/FIMER PV Inverters - SunSpec Modbus TCP

Unfortunately it’s not working:

2023-09-10 20:44:54.322 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 298, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 394, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/abb_powerone_pvi_sunspec/config_flow.py", line 90, in async_step_user
    uid = await self.test_connection(name, host, port, slave_id, base_addr, scan_interval)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/abb_powerone_pvi_sunspec/config_flow.py", line 65, in test_connection
    self.hub_data = await self.hub.async_get_data()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/abb_powerone_pvi_sunspec/api.py", line 133, in async_get_data
    self.read_sunspec_modbus_model_1()
  File "/config/custom_components/abb_powerone_pvi_sunspec/api.py", line 167, in read_sunspec_modbus_model_1
    read_model_1_data.registers, byteorder=Endian.BIG
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ModbusIOException' object has no attribute 'registers'

did you do a simple upgrade or a fresh install? I have 3 people reporting it’s working, and I’m the 4th.

Please try a fresh install of the component, and make sure slave_id and base_address are correct.

I had to delete integration since it was erroring. Later I understood maybe errors happen because of night time when inverter is off. Tried creation now since inverter is on already. The same problem. I would expect better error handling anyway :wink:

EDIT: i’ve readded repo into hacs, checked if the folder was deleted in custom components, the error is the same. I think it’s connecting to the address but something bad is returned.

Sorry but you provide no meaningful information: logs, detailed troubleshooting etc.

If the inverter is off, how did you expect for the component to work providing sensors info when you first tried?

I created an HA instance from scratch, installed the component through HACS and it’s working fine here. I’ve other users reporting it working.

Don’t know what to tell you without further debugging information for me to analyze.

And…

PRs are welcome, feel free to improve the code and submit it. :wink:

It seems I should have made it work. I’ve started Terminal, done pip install pymodbus and installed fixed 3.5.2 version. Then restarted HA and now log output is understandable (it’s evening and no generation - but it’s not crashing anymore):

2023-09-12 19:52:22.868 DEBUG (MainThread) [custom_components.abb_powerone_pvi_sunspec] Data: {'port': 502, 'slave_id': 2, 'base_addr': 0, 'scan_interval': 30, 'name': 'ABB Inverter', 'host': '192.168.9.5'}
2023-09-12 19:52:22.868 DEBUG (MainThread) [custom_components.abb_powerone_pvi_sunspec] Options: {}
2023-09-12 19:52:22.868 DEBUG (MainThread) [custom_components.abb_powerone_pvi_sunspec] Setup entry with scan interval 0:00:30. Host: 192.168.9.5 Port: 502 ID: 2
2023-09-12 19:52:22.869 DEBUG (MainThread) [custom_components.abb_powerone_pvi_sunspec] Start Get data (Slave ID: 2 - Base Address: 0)
2023-09-12 19:52:25.942 DEBUG (MainThread) [custom_components.abb_powerone_pvi_sunspec] (read_rt_1) Slave ID: 2
2023-09-12 19:52:25.942 DEBUG (MainThread) [custom_components.abb_powerone_pvi_sunspec] (read_rt_1) Base Address: 0
2023-09-12 19:52:25.942 DEBUG (MainThread) [custom_components.abb_powerone_pvi_sunspec] Finished fetching abb_powerone_pvi_sunspec data in 3.074 seconds (success: False)

Will see how it goes in the morning.

pymodbus is part of HA, you shouldn’t install it manually. If it’s not there, it means you have problems in your HA instance. Installing core libraries manually could lead to other issues.

Don’t think HA 9.1 contains fixed pymodbus 3.5.2. Wanted to try if that helps.

No, it contains 3.5.1. And if you upgrade it manually, you could have issues. Anyway…it’s your HA, do whatever you want. v3.0.0 of the component relies on pymodbus 3.5.1, and it’s working fine for many people that tested it. So I don’t know why you need pymodbus v3.5.2.

In manifest.json of the component, you can see the requirement regarding pymodbus:

{
  "domain": "abb_powerone_pvi_sunspec",
  "name": "ABB/Power-One/FIMER PVI SunSpec",
  "codeowners": ["@alexdelprete"],
  "config_flow": true,
  "documentation": "https://github.com/alexdelprete/ha-abb-powerone-pvi-sunspec",
  "integration_type": "hub",
  "iot_class": "local_polling",
  "issue_tracker": "https://github.com/alexdelprete/ha-abb-powerone-pvi-sunspec/issues",
  "loggers": ["custom_components.abb_powerone_pvi_sunspec"],
  "requirements": ["pymodbus>=3.5.1"],
  "version": "3.0.0"
}

@Claudio1L @MatteGary @anxdroid please test latest v3.1.0-beta.5: no external automation necessary anymore. I included in the component the same logic of the automation: the solution was to test if Modbus TCP was available at socket level before trying the modbus connect (pymodbus call). This avoids all the errors etc. The retry mechanism is managed by HA itself, and the integration will be online automatically as soon as the TCP port is available (inverter on) and the Modbus TCP connect is processed correctly.

Please let me know how it goes so I can release the stable version v3.1.0. Thanks.

Morning,

I found some time this weekend and tried to do something with VSN300 when inverter is on. Tried to use qmodmaster and it seems I can’t retrieve anything despite being able to connect successfully. Everything just times out. Which probably explains why I have issues with your component in HA. BTW, I’ve not setup any ABB integration in HA, so there shouldn’t be anything using the same port.
Also, I’ve restarted logger and tried toggling Modbus checkbox there too. Inverter restart hasn’t helped too. I suppose if connection works there is nothing related to something not working on local network. I remember everything working and HA reading data when I installed that VSN300 card.

Maybe you could help me from your experience please?

QModMaster is a modbus client, if it can’t retrieve data correctly, the integration won’t either.

Now you are getting me confused. I remember in June you didn’t have the VSN300 card, now you’re saying that you have it and the integration was working?

It’s difficult to help you if you can’t clear the situation for me. I don’t understand what you have (inverter model, card), what the problem was in june, what the problem is now, where is HA installed, description of the LAN, how HA connects to the VSN300, is there a firewall in between, do you filter something, do you use VLANs, etc.

If you can provide structured information maybe I can try to help. :slight_smile:

Meanwhile, install latest version of the integration, configure it, enable debug and show me the full debug log. In last version (since 3.1.x) I am checking the availability of the ip:port before connecting, so from the log I can better understand what’s going on in your setup.

image

Let it run for some minutes, then disable it, and it will automatically download the log file.

image

Thank you very much @alexdelprete for your effort to help me - it was real pleasure to discuss things with so dedicated and experienced in HA world person. All the problem was because of wrong slave ID - it was not 2 but 247. So if you see qModMaster connect but than time out on read, please make sure your slave ID is correct. It’s possible to see in Auroravision.net site in plant details here:
image

1 Like

My pleasure Ramunas, glad you now have it working. It’s a pity we can’t see the inverter id on the VSN webpage. There’s a section, but it’s empty. Glad we found out it was on auroravision.net though. :wink:

I was also thinking of implementing an Auto Slave ID function: if the check_port() passes it means we can connect to IP:PORT, but if the modbus connect fails, it means Slave ID is wrong, so we could try a list of known default IDs (2, 247 come to my mind).

And we can also say publicly (specifically to @monkeypr00f and @wrongisthenwright, that helped me test the VSN REST authentication) that you kindly offered your invaluable professional help for the implementation of the REST/JSON version of the integration. I hope it won’t be too difficult, I only developed the auth and I got the json response, now we have to parse it and put it in sensors. :slight_smile:

Hi Alex,

i have problems to connect to the Inverter, i think it is since a HA Core Update. I deleted the integration and installed your latest version, on the config-setup i always get a connection error!


If i connect with internet-browser to the inverter i can get on the dashboard of the ABB, so the IP and connection works.

Just tried with QModMaster and it can’t get a connection! Strange…

Can you help?

If you can’t connect with qmodmaster, you will not connect with the component.

Check your parameters, in particular the slave ID one.

You can enable debug on the component and retry, then show the debug log so I can see exactly where the connect is failing.

earlier it was running well (see this thread), so Slave ID 247 and IP are correct.
I cant enable debug because i dont come out of the config-box.

Could it be that the inverter did a automatic firmware update or something like that?
In Modbus TCP is Sunspec Protocol aktivatet.
No other Devices like Smartmeter are connected.

How can i reboot the Inverter? What is the Admin+ password?

Debug on the custom component, on HA integrations.

No, the inverter doesn’t do automatic fw upgrades.

You reboot the VSN card, not the inverter, from the web interface of the VSN300/VSN700 or system you’re using. I don’t know because you didn’t specifiy anything.

You need to check the manual of your system, since I don’t know what card you use, I can’t help.

VSN Card? I dont think i have such.
What should it be? I dont use WiFI, only LAN.
I cant remember, but was it beside the Inverter-Package?

My Model is the ABB React2 3.6TL

Probably it has it embedded, or some other card, I don’t know: you are the owner, you should know what you bought. :slight_smile:

I am sorry, but i cannot find anything to debug, on HA integrations i only can add a new Integration “ABB …” wich starts with the config-screen.

here a screenshot of the Modbus Part of the Inverter,
is here something missing?

very strange that QModMaster cannot connect to TCP port…
So i think it no issui with HA or the Integration but rather with the inverter.