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

Ciao,

  1. what type of HA installation do you use? supervised, core, etc.
  2. do you use other integrations that leverage pymodbus?
  3. how are you installing the component, manually or hacs?

Ciao, I’m using HA core.
Not sure about other integrations using pymodbus honestly, do you know how can I check it? I’m was using modbus for communicating directly with the inverter, but it doesn’t work anymore:

modbus:
  type: tcp
  host: 192.168.1.170
  port: 502
- platform: modbus
  registers:
    - name: Fotovoltaico-Output
      unit_of_measurement: W
      slave: 1
      register: 40084
      register_type: holding  
      scale: 10

etc…

The component is installed using HACS.

If it can be of any help, the error is logged with another error of another integration:

Error occurred loading configuration flow for integration tuya: cannot import name 'AuthType' from 'tuya_iot' (/srv/homeassistant/lib/python3.10/site-packages/tuya_iot/__init__.py)
Error occurred loading configuration flow for integration abb_powerone_pvi_sunspec: cannot import name 'ModbusTcpClient' from 'pymodbus.client' (/srv/homeassistant/lib/python3.10/site-packages/pymodbus/client/__init__.py)

if the modbus native integration doesn’t work, probably you have an issue with the installation of pymodbus. that’s why also my component gives you errors. What errors does the native modbus integration give you? Show the log.

you need to fix that problem first, otherwise it won’t work, as it is a prerequirement.

check if you installed other components that use modbus so probably they install/require pymodbus library. maybe there’s some conflict, but I can’t help you more than that.

you can also try with a backup of the config, reinstall HA and restore the config. then try the modbus: integration first, once that works, you can use my component too because it means pymodbus is working.

One thing you might want to check: open a shell inside the container and do this command: find / -name 'pymodb*'

It will find all pymodbus installation folders, so we can check specific things. Paste the output of that command here.

This is the output of find command:

root@raspberrypi:~# find / -name 'pymodb*'
find: ‘/proc/20814’: File o directory non esistente
find: ‘/proc/20824’: File o directory non esistente
find: ‘/proc/20825’: File o directory non esistente
find: ‘/proc/20826’: File o directory non esistente
find: ‘/proc/20827’: File o directory non esistente
/usr/local/lib/python3.7/dist-packages/pymodbus
/usr/local/lib/python3.7/dist-packages/pymodbus-2.5.3.dist-info
/usr/local/bin/pymodbus.console
/usr/local/bin/pymodbus.server
/srv/homeassistant/lib/python3.10/site-packages/pymodbus
/srv/homeassistant/lib/python3.10/site-packages/pymodbus-3.0.0.dist-info
/srv/homeassistant/bin/pymodbus.console
/srv/homeassistant/bin/pymodbus.server

I updated recently to python3.10, might it be I did something wrong when updating? How can I know which pymodbus package is HA using, whether 3.7 or 3.10?

What HA version are you using?

Troubleshooting for Core: Common Tasks - Core - Home Assistant (home-assistant.io)

How did you upgrade python? If you use core bare metal, you have to follow a procedure, that’s why I advise to use the container version if you don’t want to get mad with dependencies/venv/etc.

Here’s a detailed procedure for python upgrade on core bare metal: Upgrading HomeAssistant Core in a Python VE - Community Guides - Home Assistant Community (home-assistant.io)

I’m using the latest, 2022.11.2.
I tried the troubleshooting, with no luck (it tried to install pymodbus, though, and not the latest version).

For upgrading python I followed this guide:

I was to thinking to migrate to Docker, maybe it’s easier for people who it’s not very expert like me…

If you’re not an expert, I strongly advice using supervised installation. Or, if you don’t like being supervised, core on docker. you can easily migrate, prepare a backup of the config first. :slight_smile:

That article is a bomb for breaking an installation, for non advances users. They should warn people.

I tried migrating, everything works as before the migration, but your package does’t install either… :frowning:

I just installed a test HA on a new server, everything from scratch. First thing I installed HACS, then I added my repo, added the ABB component, added the integration:

Everything working perfectly.

Sorry, I don’t know what you do, but clearly you have issues with your configuration.

1 Like

That’s helpful anyway, I will concentrate on my configuration instead on concentrating on installation of packages like pymodbus…

Edit: I tried myself instantiating a new HA installation on docker, and, in fact, your package works. Maybe I’m missing something: when running HA core, it uses pymodbus from /srv/homeassistant/lib/python3.10/site-packages/pymodbus

When running on Docker, does it get pymodbus from the same folder or elsewhere?

Edit2: looking around, I guess I can answer myself, and the when using docker, the HA installation is inside the docker, and pymodbus I guess it’s this one:

/var/lib/docker/overlay2/e3d22a5c5efdb1081b2232bdedeb236c8dafca35b8e4d596267ba23badbec3b1/diff/usr/local/lib/python3.10/site-packages/pymodbus
/var/lib/docker/overlay2/e3d22a5c5efdb1081b2232bdedeb236c8dafca35b8e4d596267ba23badbec3b1/diff/usr/local/lib/python3.10/site-packages/pymodbus-2.5.3.dist-info

The core installation uses pymodbus version 3.0.0. I tried removing pymodbus installations:

sudo -u homeassistant -H -s
source /srv/homeassistant/bin/activate
pip uninstall pymodbus

Then trying again to add your integration, from logs I get:

2022-11-16 13:25:31.198 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of pymodbus==3.0.0
2022-11-16 13:25:39.317 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration abb_powerone_pvi_sunspec: cannot import name 'ModbusTcpClient' from 'pymodbus.client' (/srv/homeassistant/lib/python3.10/site-packages/pymodbus/client/__init__.py)

Version 3.0.0 is correctly installed after I get this message, but it’s a different version compared to the one in docker. Does your package have a specific version as a pre-requisite?

I also tried removing all pymodbus installations, and got the same message. I then tried removing all installations and install pymodbus 2.5.3, and when I try adding your integration, it tries to install 3.0.0 anyway and the log shows again the same message:

2022-11-16 13:25:31.198 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of pymodbus==3.0.0
2022-11-16 13:25:39.317 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration abb_powerone_pvi_sunspec: cannot import name 'ModbusTcpClient' from 'pymodbus.client' (/srv/homeassistant/lib/python3.10/site-packages/pymodbus/client/__init__.py)

You can see from the log the version my component needs: Attempting install of pymodbus==3.0.0. The component requires 3.0.0. You can see it from the manifest.json file in component’s directory:

"requirements": ["pymodbus==3.0.0"]

It’s not a different version, it’s 3.0.0, and it’s installed by HA, not by the component, and HA puts python modules in the appropriate directory.

I don’t know what kind of tests you are doing, removing system components, reinstalling them manually…whatever.

Do a clean installation of HA, install my component, and you’ll see it is correctly installed and it works. All the rest are tests you are doing trying to prove I don’t know exactly what: you think that manually removing pymodbus from a standard installation is a proper test?

I’m not trying to prove your component doesn’t work, I’m just trying to make my installation work, I’d avoid to start from scratch with a clean HA installation, I would need to reconfigure all.

But maybe you are right, it would take less time that what I’m doing…

I finally found what was bothering the installation of your component. It’s having this in the configuration:

modbus:
  type: tcp
  host: 192.168.1.170
  port: 502
- platform: modbus
  registers:
    - name: Fotovoltaico-Output
      unit_of_measurement: W
      slave: 1
      register: 40084
      register_type: holding  
      scale: 10

I don’t know why of course, but at least now it works…

I asked you since the beginning if you had other components accessing modbus…you said you didn’t know, that you were using modbus: native integration, etc. If you use my component, why are you using modbus: native integration to access the same inverter? They’re in conflict. Try changing the IP of the native modbus:, just to double-check that the problem is the fact they’re both accessing the same device.

I use my component for my inverter and I also use modbus: native for another device for which there’s no component yet (Alfa by Sinapsi, I’m preparing it), and everything works fine.

And i replied to you too :slight_smile: check messages from 4 days ago. I was using that modbus connection at the beginning, and it worked, but after a while it didn’t work anymore, don’t know why.
If it can be useful, I was able to read other values compared to your component, so maybe it can be useful for you to integrate the register values for inverter UNO-DM-6.0-TL-PLUS, for example the values of the different strings.
I copy paste here the configuration:

registers:
    - name: Fotovoltaico-Output
      unit_of_measurement: W
      slave: 1
      register: 40084
      register_type: holding  
      scale: 10      
    - name: Fotovoltaico -  Output Volt
      unit_of_measurement: V
      slave: 1
      register: 40080
      register_type: holding  
      scale: 0.1
    - name: Fotovoltaico_Output_Amp
      unit_of_measurement: A
      slave: 1
      register: 40073
      register_type: holding  
      scale: 0.1
      precision: 1
    - name: Fotovoltaico -  Lato DC Output
      unit_of_measurement: W
      slave: 1
      register: 40101
      register_type: holding  
      scale: 10      
    - name: Fotovoltaico -  Totale
      unit_of_measurement: KWh
      slave: 1
      register: 40187
      register_type: holding
      count: 4
      scale: 0.001
      precision: 2
    - name: Fotovoltaico -  String 1 Output
      unit_of_measurement: W
      slave: 1
      register: 41125
      register_type: holding  
      scale: 10  
      data_type: uint  
    - name: Fotovoltaico -  String 1 Volt
      unit_of_measurement: V
      slave: 1
      register: 41124
      register_type: holding  
      scale: 0.1
      data_type: uint
    - name: Fotovoltaico -  String 1 Amp
      unit_of_measurement: A
      slave: 1
      register: 41123
      register_type: holding  
      scale: 0.1
      precision: 1
    - name: Fotovoltaico -  String 2 Output
      unit_of_measurement: W
      slave: 1
      register: 41145
      register_type: holding  
      scale: 10  
      data_type: uint      
    - name: Fotovoltaico -  String 2 Volt
      unit_of_measurement: V
      slave: 1
      register: 41144
      register_type: holding  
      scale: 0.1
      data_type: uint       
    - name: Fotovoltaico -  String 2 Amp
      unit_of_measurement: A
      slave: 1
      register: 41143
      register_type: holding  
      scale: 0.1
      precision: 1
    - name: Fotovoltaico -  Probe Sys
      unit_of_measurement: °C
      slave: 1
      register: 40103
      register_type: holding  
      scale: 0.1
      precision: 1
    - name: Fotovoltaico -  Probe AC
      unit_of_measurement: °C
      slave: 1
      register: 40104
      register_type: holding  
      scale: 0.1
      precision: 1
    - name: Fotovoltaico -  Probe DC
      unit_of_measurement: °C
      slave: 1
      register: 40106
      register_type: holding  
      scale: 0.1
      precision: 1

Did you test my component? it reads those values, I have a 3-phase inverter with two strings:

I did, but the 2 strings are not shown:

that’s the view you built, show me the sensors on the device page…it’s impossible you don’t see all the sensors.

BTW: your model is not in the list, I will add it. Do you have an error msg in HA log saying to contact me and provide some info, right? I see Options: 0x10ED. So your model is 0x10 and it is a UNO-DM-6.0-TL-PLUS.

I added all the sensor from the “devices” tab.
Here is the view:

Same if I check Entities:

Here is the error for the unknown model:

Questo errore ha avuto origine da un'integrazione personalizzata.

Logger: custom_components.abb_powerone_pvi_sunspec
Source: custom_components/abb_powerone_pvi_sunspec/__init__.py:145
Integration: ABB Power-One PVI SunSpec (documentation, issues)
First occurred: 11:28:57 (788 occurrences)
Last logged: 17:26:01

(opt_comm_model) Model unknown, report to @alexdelprete on the forum the following data: Manuf.: ABB - Model: -3P31- - Options: 0x10ED/0xFF69/ - OptModel: 0x10ED/0xFF69/ - OptModelInt: 16
(read_inv) Reading data failed! Please check Slave ID: 247
(read_inv) Reading data failed! Please check Reg. Base Address: 40000
(read_data) Reading data failed! Please check Slave ID: 247
(read_data) Reading data failed! Please check Reg. Base Address: 40000