-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Component error: modbus - Exception importing homeassistant.components.modbus #85869
Comments
Hey there @adamchengtkc, @janiversen, @vzahradnik, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) modbus documentation |
It does look like the pymodbus library is some weird version. Or something is breaking that library. I didnt see anything strange with Huawei Solar. Do you have anything else using modbus? |
I do not have anything else that could be using modbus, in fact though, I did try to disable Huawei Solar, reboot HA, and the modbus integration does operate normally, so I assume that is a clear culprit somehow. Upon attempting to re enable Huawei Solar, the following error triggered. What is the best next step here? Pinging @wlcrs for any comments you might have here, I imagine the official guidance is to close this and move the issue in the Huawei Solar repository, I'm going to be standing by for guidance, thanks in advance! `Logger: homeassistant.setup Setup failed for custom integration huawei_solar: Unable to import component: cannot import name 'AsyncModbusSerialClient' from 'pymodbus.client' (/usr/local/lib/python3.10/site-packages/pymodbus/client/init.py)` |
Yes ut seems it pulls in a later version of the lib. Which is strange since it mentions same version as core as supported. |
Found it. Huawei solar dev version uses 3.0.0 version of pymodbus. You must use main version to be compatible with core. Would be good to bump modbus to 3.0.0 in core and support that version of pymodbus instead. |
The maintainer of pyModbus @janiversen has already signalled to me that he would upgrade the Modbus integration to pyModbus 3.x.x . The huawei_solar beta version already uses this new pyModbus version, and will stay in beta until the version conflict with pyModbus in core is resolved. |
This is not a modbus integration problem, you use a custom component that uses another version of pymodbus (which are known to have a couple of serious problems). |
Thanks everyone, moving back to stable for Huawei Solar has enabled both integrations to work as expected, even though that means losing many Huawei Solar great new developments in the dev branch! This seemingly would still allow me to change the max battery grid charge for the Huawei inverter as I was planning to, dynamically with the second older SMA modbus inverter production yields, so no issues my end closing this and waiting for further developments. @janiversen can you help us all understand, though, does the serious problems you mention hinder a realistic possibility for modbus in core to be utilizing 3.1.0 pymodbus anytime soon? What are those issues can you expand, just so @wlcrs can consider them given Huawei Solar has been working well with it since a while, including expecting alignment as per the above, in order to promote a dev branch to stable? Last reflection to share, looking at the repo, only pymodbus 3.x supports Python 3.10 whilst 2.x supports until 3.7, and I see from the logs that HASSOS utilizes Python 3.10. It would seem a requirement that modbus aligns, as we would otherwise have a core integration not compatible officially with the python HASSOS version, whereby not even tests are run against python 3.10 based on pymodbus 2.x repo, in turn meaning even if we are functional now, this can break the whole HASSOS at any time, i.e., from what we understood from this finding here, the whole system might not even start/reboot! |
I happen to maintain the pymodbus library as well, that should be enough reason ! you are not reading the README correctly. v2.5.3 run nicely on python version to at least 3.10, but v3+ only runs on python version 3.8 and higher. Please do not forget the custom integration do not use e.g. the climate entity, the modbus integration is general and needs to support many different use cases. As a rule, core do not adapt to custom integrations, it would be an endless loop (one custom integration uses a new version, while another uses an older version). The recommendation to custom integrations is to: a) Use the integration in core, by importing and calling the methods. That way the custom integration is independent of library changes. I am planning a series of updates to both pymodbus and the modbus integration over the next months, so unless the custom integration upgrades with the same tact there will be instability. I have no idea why the Huawai solar integration was updated to use a new (and for our use, untested) version. I have a Huawei SUN2000 Tkl, and it works fine with the modbus integration, but I agree the that the custom integration provides some niceties. So in short, because this custom integration have chosen not to use the same library version as core, the users face a problem, but please do not make it my problem, the modbus integration runs stable and that is my major goal. I am in the final rounds of testing a new library version (3.1.0)....but if core starts using that, you will see the opposite conflict, because then there will still be a version conflict. |
In reality I am not sure I understand why the custom integration choose solely to use the new version. I have a version of the modbus integration that works on both library version, which I am using to test. All differences is isolated in one .py file. At least for the mudbus integration there are no functional advantages in using pymodbus 3.1.0 (but when changing to async there will be). |
Thanks Jan for the extensive explanation, much appreciated and in alignment, also it's great to get to know you're indeed maintaining both the library and integration, I didn't spot that and in fact it tells the fuller story on its own |
I clearly misinterpreted the intended timeline when Jan said on October 30th in issue pymodbus-dev/pymodbus#1146 (comment) that "HomeAssistant modbus integration is also due to be bumped to use the new library.". As stated by Jan in this issue: keeping library versions in sync between integrations is impossible, be it core or non-core integrations. I will not attempt to keep compatibility by doing retrofits etc. The current dev/beta-version of the huawei_solar will be promoted to stable once the pymodbus-dependency of the modbus-component in core is upgraded to 3.x.x . |
In October I planned to use pymodbus v3.0.2, but then we found a serious problem in the serial part, which meant the modbus integration could not use v3.0.2. I opened a PR in the asyncio-pyserial repo but that was not responded to (and still not is) so we had to go down another route, all of this causing delays, and now finally the modbus integration is using v3.1.0 on dev, but I suspect the custom integration needs some smaller update due to some api differences between v3.0.2 and v3.1.0. |
Hello, I wanted to install the Huawei Solar integration for the first time. I'm installing it via HACS but when I try to configure it I get the error "the configuration flow could not be charged {"message":"Invalid handler **specified"}" (note: I have it in French so the exact wording may differ). Looking at the logfile, this relates to a issue with the pymodbus library.
I'm using HA 2023.1.7. I tried the integration version 1.2.0 and (after de-installing and rebooting) version 1.1.6. Both give the error. What should I do to be able to install this integration? Alternatively, instead of going via the configuration UI, is there a sample yaml that I could copy and update manually to get it running? Many thanks for your help |
We do not support custom integration, they are as the name says “custom” ! Please deinstall the custom integration and see if the core modbus integration works, if not then it is a problem we will look into. Remark: this issue is closed, for the same reason, so please if you have problems with the core modbus integration please open a new issue. |
The problem
Adding ModBus integration does not succeed and triggers the following error, blocking HA from restarting and loading it.
Component error: modbus - Exception importing homeassistant.components.modbus
Attempted to, with the same result:
Thanks!
What version of Home Assistant Core has the issue?
2023.1.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
modbus
Link to integration documentation on our website
https://www.home-assistant.io/integrations/modbus
Diagnostics information
N/A
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
Modbus does not load regardless of the configuration parameters, which seems to be the main issue. The connection to the host that is being attempted, shall be working as per the previous experience and settings shared here . I'd assume the integration is not designed to hard fail when unable to connect to the host.
Useful to know, yet not too sure of the interactions (expecting none), is that the Huawei Solar HACS integration is running and is connecting through ModBus too, so the the issue could be:
The text was updated successfully, but these errors were encountered: