WouterTuinstra / Homeassistant-Growatt-Local-Modbus

Provides Home Assistant sensors for Growatt inverters that you can connect directly using modbus protocol
Apache License 2.0
25 stars 13 forks source link

[BUG] HA 2024.02.0 integration not start #27

Closed Saentist closed 7 months ago

Saentist commented 7 months ago

After update Integration do not start

Core 2024.2.0
Supervisor 2024.01.1
Operating System 11.5
Frontend 20240207.0
Invalid config
The following integrations and platforms could not be set up:
growatt_local Show logs
Logger: homeassistant.setup
Source: setup.py:251
First occurred: 08:49:19 ч. (1 occurrences)
Last logged: 08:49:19 ч.

Setup failed for custom integration 'growatt_local': Unable to import component: cannot import name 'ModbusBaseClient' from 'pymodbus.client' (/usr/local/lib/python3.12/site-packages/pymodbus/client/__init__.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 827, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/growatt_local/__init__.py", line 56, in <module>
    from .API.growatt import GrowattDevice, GrowattSerial, GrowattNetwork
  File "/config/custom_components/growatt_local/API/growatt.py", line 17, in <module>
    from pymodbus.client import ModbusBaseClient
ImportError: cannot import name 'ModbusBaseClient' from 'pymodbus.client' (/usr/local/lib/python3.12/site-packages/pymodbus/client/__init__.py)
WouterTuinstra commented 7 months ago

Which version is currently installed of pymodbus because there is a range of releases where the ModbusBaseClient in not included in the pymodbus/client/__init__.py this has been fixed in the most recent release 3.6.4 see also following commit: https://github.com/pymodbus-dev/pymodbus/commit/66af5b67058605c81854e872b0ff3f612dcb278e

Saentist commented 7 months ago

Any example how to get version? I use Home Assistant HAOS in ESXI server https://www.home-assistant.io/installation/alternative everything is preinstalled

Saentist commented 7 months ago
Support for pyModbus below 3.5.2 has been dropped, for HA installations older than 2023.9.0
Integration 2023.09.3 is the last supported version

No idea what is current version.

Nick-Innes commented 7 months ago

I'm suffering the same error message, and the integration failing to start once I upgraded from 2024.1.x to 2024.2.1, and the issue persists after upgrading to 2024.2.2, and removing and reinstalling the integration via HACS.

Saentist commented 7 months ago

How you remove it it's impossible, delete not working?

Nick-Innes commented 7 months ago

I removed the folder below custom_components and then told HACS to ignore that it was configured. I then restarted home assistant a couple of times and reinstalled using HACS, only to find I was exactly where I'd started. I'd been hoping that 2024.2.2 or later would maybe update pyModbus or similar, but no such luck. I've nothing else using Modbus, except the GivTCP add-on, but that's in a different container.

WouterTuinstra commented 7 months ago

I updated the manifest.json file with the requirements to use the latest version of pymodbus this should automatically solve the issue because HA will check the required packages.

Saentist commented 7 months ago

Still have this message

Invalid config
The following integrations and platforms could not be set up:

[growatt_local] ([Show logs])
Please check your config and [logs].
Logger: homeassistant.setup
Source: setup.py:251
First occurred: 17:03:58 ч. (1 occurrences)
Last logged: 17:03:58 ч.

Setup failed for custom integration 'growatt_local': Unable to import component: cannot import name 'ModbusBaseClient' from 'pymodbus.client' (/usr/local/lib/python3.12/site-packages/pymodbus/client/__init__.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 827, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/growatt_local/__init__.py", line 56, in <module>
    from .API.growatt import GrowattDevice, GrowattSerial, GrowattNetwork
  File "/config/custom_components/growatt_local/API/growatt.py", line 17, in <module>
    from pymodbus.client import ModbusBaseClient
ImportError: cannot import name 'ModbusBaseClient' from 'pymodbus.client' (/usr/local/lib/python3.12/site-packages/pymodbus/client/__init__.py)
WouterTuinstra commented 7 months ago

Have you updated the integration because I have no issues. At restart it should state the following: Attempting install of pymodbus>=3.6.4

Saentist commented 7 months ago

Have you updated the integration because I have no issues. At restart it should state the following: Attempting install of pymodbus>=3.6.4

Yes I update it it show now d294ebf revision aka hash of lasted commit.

WouterTuinstra commented 7 months ago

I don't know why it would not update on your side best to otherwise do it manual but I don't know how to get access to Home Assistant in an ESXI environment

Saentist commented 7 months ago

There is "Advanced SSH & Web Terminal" addon and some docker access later.

WouterTuinstra commented 7 months ago

Use the "Advanced SSH & Web Terminal" and execute the following commands: pip show pymodbus pip install pymodbus==3.6.4

Saentist commented 7 months ago

I guess i need to be in some docker crap before call this image

Strange before it was working

Second command do something image

And after restart it work, but sun is not enough to see values.

WouterTuinstra commented 7 months ago

Strange that initially not even recognized the package.

Nick-Innes commented 7 months ago

Thank you! I updated the custom component yesterday and when the sun returned today everything worked perfectly again!

Saentist commented 7 months ago

@WouterTuinstra just after update to Release 2024.2.3 immediately block integration and need to install pymodbus again.

other integration with use pymodbus have this:

"requirements": ["pymodbus>=3.5.2"],
"version": "2024.02.6"
WouterTuinstra commented 7 months ago

I'm not sure why it's not installing pymodbus but that would be a problem in HA itself and not in this intergration.

Saentist commented 7 months ago

I'm not sure why it's not installing pymodbus but that would be a problem in HA itself and not in this intergration.

Solax integration use it but not sure how, without need to install it as in this case.

https://github.com/home-assistant/core/tree/dev/homeassistant/components/modbus

# homeassistant.components.modbus
pymodbus==3.6.4

I see some string

from pymodbus.exceptions import ModbusException
import pytest

not sure is this connected

Saentist commented 7 months ago

@WouterTuinstra Again update again failed to start reload missing, need full reload of HA image need to be something as this image after install pymodbus image

Solax integration have this in init.py

_LOGGER = logging.getLogger(__name__)
#try: # pymodbus 3.0.x
from pymodbus.client import AsyncModbusTcpClient, AsyncModbusSerialClient

#    UNIT_OR_SLAVE = 'slave'
#    _LOGGER.warning("using pymodbus library 3.x")
#except: # pymodbus 2.5.3
#    from pymodbus.client.sync import ModbusTcpClient, ModbusSerialClient
#    UNIT_OR_SLAVE = 'unit'
#    _LOGGER.warning("using pymodbus library 2.x")
#import pymodbus
#_LOGGER.debug(f"pymodbus client version: { pymodbus.__version__ }")
#if pymodbus.__version__.startswith('3.3') or pymodbus.__version.startswith('3.0'):
#    Endian_BIG = Endian.big
#    Endian_LITTLE = Endian.little
#else:
#    Endian_BIG = Endian.BIG
#    Endian_LITTLE = Endian.LITTLE
from pymodbus.constants import Endian
from pymodbus.exceptions import ConnectionException
from pymodbus.payload import BinaryPayloadBuilder, BinaryPayloadDecoder, Endian
from pymodbus.transaction import ModbusRtuFramer, ModbusAsciiFramer
Saentist commented 7 months ago

@WouterTuinstra today's update show pymodbus as installed but there is some difference.

Logger: homeassistant.setup
Source: setup.py:251
First occurred: 15:09:35 ч. (1 occurrences)
Last logged: 15:09:35 ч.

Setup failed for custom integration 'growatt_local': Unable to import component: cannot import name 'ModbusBaseClient' from 'pymodbus.client' (/usr/local/lib/python3.12/site-packages/pymodbus/client/__init__.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 827, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/growatt_local/__init__.py", line 56, in <module>
    from .API.growatt import GrowattDevice, GrowattSerial, GrowattNetwork
  File "/config/custom_components/growatt_local/API/growatt.py", line 17, in <module>
    from pymodbus.client import ModbusBaseClient
ImportError: cannot import name 'ModbusBaseClient' from 'pymodbus.client' (/usr/local/lib/python3.12/site-packages/pymodbus/client/__init__.py) 

but pymodbus is in different location

image

image