Skip to content
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

Modbus problem in 2024.4.0 and 2024.4.1 #115114

Closed
e6on opened this issue Apr 7, 2024 · 22 comments
Closed

Modbus problem in 2024.4.0 and 2024.4.1 #115114

e6on opened this issue Apr 7, 2024 · 22 comments

Comments

@e6on
Copy link

e6on commented Apr 7, 2024

The problem

After core update to 2024.4.0 Modbus fails to read data.

What version of Home Assistant Core has the issue?

2024.4.0 and 2024.4.1

What was the last working version of Home Assistant Core?

2024.3.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

komfovent.yaml

Link to integration documentation on our website

No response

Diagnostics information

modbus.log

Example YAML snippet

modbus:
  - name: komfovent
    type: tcp
    host: 192.168.168.6
    port: 502
    message_wait_milliseconds: 30

    switches:
      - name: "Komfovent Eco Mode"
        address: 2
        command_on: 1
        command_off: 0
        verify:

    sensors:
      - name: "Komfovent Power"
        address: 0
        input_type: holding
        data_type: uint16
        scan_interval: 5
      - name: "Komfovent Eco"
        address: 2
        input_type: holding
        data_type: uint16
        scan_interval: 30
      - name: "Komfovent Auto"
        address: 3
        input_type: holding
        data_type: uint16
        scan_interval: 30
      - name: "Komfovent Mode"
        address: 4
        input_type: holding
        data_type: uint16
        scan_interval: 30
      - name: "Komfovent Status bit mask"
        address: 899
        input_type: holding
        data_type: uint16
        scan_interval: 5
      - name: "Komfovent Supply temperature 'C"
        address: 901
        input_type: holding
        data_type: int16
        scan_interval: 10
        unit_of_measurement: °C
        scale: 0.1
        precision: 1
        device_class: temperature
        state_class: measurement
      - name: "Komfovent Extract temperature 'C"
        address: 902
        input_type: holding
        data_type: int16
        scan_interval: 10
        unit_of_measurement: °C
        scale: 0.1
        precision: 1
        device_class: temperature
        state_class: measurement
      - name: "Komfovent Outdoor temperature 'C"
        address: 903
        input_type: holding
        data_type: int16
        scan_interval: 10
        unit_of_measurement: °C
        scale: 0.1
        precision: 1
        device_class: temperature
        state_class: measurement
      - name: "Komfovent Supply Fan Intensivity '%"
        address: 909
        input_type: holding
        data_type: uint16
        scan_interval: 30
        unit_of_measurement: '%'
        scale: 0.1
        precision: 1
        state_class: measurement
      - name: "Komfovent Extract Fan Intensivity '%"
        address: 910
        input_type: holding
        data_type: uint16
        scan_interval: 30
        unit_of_measurement: '%'
        scale: 0.1
        precision: 1
        state_class: measurement
      - name: "Komfovent Heat exchanger, %"
        address: 911
        input_type: holding
        data_type: uint16
        scan_interval: 30
        unit_of_measurement: '%'
        scale: 0.1
        precision: 0
        state_class: measurement
      - name: "Komfovent Electric Heater %"
        address: 912
        data_type: uint16
        input_type: holding
        scale: 0.1
        precision: 1
        unit_of_measurement: '%'
        state_class: measurement
        scan_interval: 30
      - name: "Komfovent Filter Impurity, %"
        address: 916
        input_type: holding
        data_type: uint16
        scan_interval: 100
        unit_of_measurement: '%'
        state_class: measurement
      - name: "Komfovent Power consumption, W"
        address: 920
        input_type: holding
        data_type: uint16
        scan_interval: 30
        unit_of_measurement: W
        device_class: power
        state_class: measurement
      - name: "Komfovent Heating power, W"
        address: 921
        input_type: holding
        data_type: uint16
        scan_interval: 30
        unit_of_measurement: W
        device_class: power
        state_class: measurement
      - name: "Komfovent Heat Recovery, W"
        address: 922
        input_type: holding
        data_type: uint16
        scan_interval: 10
        unit_of_measurement: W
        device_class: power
        state_class: measurement
      - name: "Komfovent Heat exchanger efficiency, %"
        address: 923
        input_type: holding
        data_type: uint16
        scan_interval: 10
        scale: 1
        precision: 0
        unit_of_measurement: '%'
        state_class: measurement
      - name: "Komfovent Energy saving, %"
        address: 924
        input_type: holding
        data_type: uint16
        scan_interval: 10
        unit_of_measurement: '%'
        state_class: measurement
      - name: "Komfovent Power consumption Month, kWh"
        address: 928
        input_type: holding
        data_type: uint32
        scan_interval: 30
        unit_of_measurement: kWh
        precision: 0
        scale: 0.001
        device_class: energy
      - name: "Komfovent Power consumption Total, kWh"
        address: 930
        input_type: holding
        data_type: uint32
        scan_interval: 30
        unit_of_measurement: kWh
        precision: 0
        scale: 0.001
        state_class: total_increasing
        device_class: energy
      - name: "Komfovent Heating Recovery Month, kWh"
        address: 940
        input_type: holding
        data_type: uint32
        scan_interval: 30
        unit_of_measurement: kWh
        precision: 0
        scale: 0.001
        device_class: energy

Anything in the logs that might be useful for us?

No response

Additional information

No response

@janiversen
Copy link
Member

janiversen commented Apr 7, 2024

Please add a debug log as pr modbus integration documentation.

Please also reduce your config, to the essential needed to show the problem, if you want us to use time helping you, it seems fair you use time to present the problem in a short form.

@e6on
Copy link
Author

e6on commented Apr 7, 2024

Modbus debug log is already added under the "Diagnostics information" label.

@janiversen
Copy link
Member

Please reduce your config to a small one showing the problem, you cannot expect us to use time browsing through your total configuration

@janiversen
Copy link
Member

janiversen commented Apr 7, 2024

Please let me see the first part of homeassistant.log, it seems you have custom_components active, and that the pymodbus library is not updated.

I am trying to reproduce the problem in the first lines of the debug.log, and when I test with your setup I do not get any errors.

@janiversen
Copy link
Member

According to you 2024.3.3 works...now the very strange thing is that the pymodbus library version (from where the error message comes) have NOT changed.

With the log you provided I cannot reproduce your problem, meaning you either have another problem earlier or your installation is not correctly updated.

@janiversen janiversen reopened this Apr 7, 2024
@crug80
Copy link
Contributor

crug80 commented Apr 7, 2024

Hi @janiversen , I can confirm that something is going wrong in modbus with latest update. Here a short piece of log. I cannot do more test because my dev raspberry is gone and I need modbus active in my production server.. I'll try to setup a new dev board in the next days.
024-04-07 23:12:26.765 DEBUG (MainThread) [pymodbus.logging] Connecting to /dev/ttyUSB0. 2024-04-07 23:12:26.765 DEBUG (MainThread) [pymodbus.logging] Connecting comm 2024-04-07 23:12:26.767 DEBUG (MainThread) [pymodbus.logging] Connected to comm 2024-04-07 23:12:26.789 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1 2024-04-07 23:12:26.789 DEBUG (MainThread) [pymodbus.logging] send: 0x1 0x3 0x0 0x6e 0x0 0x1 0xe5 0xd7 2024-04-07 23:12:26.821 DEBUG (MainThread) [pymodbus.logging] recv: 0x1 0x3 0x2 0x0 0x34 0xb9 0x93 old_data: addr=None 2024-04-07 23:12:26.821 DEBUG (MainThread) [pymodbus.logging] Processing: 0x1 0x3 0x2 0x0 0x34 0xb9 0x93 2024-04-07 23:12:26.821 DEBUG (MainThread) [pymodbus.logging] Frame - not ready 2024-04-07 23:12:31.791 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1 2024-04-07 23:12:31.791 DEBUG (MainThread) [pymodbus.logging] send: 0x1 0x3 0x0 0x6e 0x0 0x1 0xe5 0xd7 2024-04-07 23:12:31.828 DEBUG (MainThread) [pymodbus.logging] recv: 0x1 0x3 0x2 0x0 0x34 0xb9 0x93 old_data: addr=None 2024-04-07 23:12:31.828 DEBUG (MainThread) [pymodbus.logging] Processing: 0x1 0x3 0x2 0x0 0x34 0xb9 0x93 2024-04-07 23:12:31.828 DEBUG (MainThread) [pymodbus.logging] Frame - not ready 2024-04-07 23:12:36.792 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1 2024-04-07 23:12:36.792 DEBUG (MainThread) [pymodbus.logging] send: 0x1 0x3 0x0 0x6e 0x0 0x1 0xe5 0xd7 2024-04-07 23:12:36.819 DEBUG (MainThread) [pymodbus.logging] recv: 0x1 0x3 0x2 0x0 0x34 0xb9 old_data: addr=None 2024-04-07 23:12:36.820 DEBUG (MainThread) [pymodbus.logging] Processing: 0x1 0x3 0x2 0x0 0x34 0xb9 2024-04-07 23:12:36.820 DEBUG (MainThread) [pymodbus.logging] Frame - not ready 2024-04-07 23:12:36.835 DEBUG (MainThread) [pymodbus.logging] recv: 0x93 old_data: addr=None 2024-04-07 23:12:36.836 DEBUG (MainThread) [pymodbus.logging] Processing: 0x93 2024-04-07 23:12:36.836 DEBUG (MainThread) [pymodbus.logging] Frame - not ready 2024-04-07 23:12:41.794 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1 2024-04-07 23:12:41.795 DEBUG (MainThread) [pymodbus.logging] send: 0x1 0x3 0x0 0x6e 0x0 0x1 0xe5 0xd7 2024-04-07 23:12:41.827 DEBUG (MainThread) [pymodbus.logging] recv: 0x1 0x3 0x2 0x0 0x34 0xb9 0x93 old_data: addr=None 2024-04-07 23:12:41.827 DEBUG (MainThread) [pymodbus.logging] Processing: 0x1 0x3 0x2 0x0 0x34 0xb9 0x93 2024-04-07 23:12:41.827 DEBUG (MainThread) [pymodbus.logging] Frame - not ready 2024-04-07 23:12:46.796 DEBUG (MainThread) [pymodbus.logging] Connection lost comm due to Server not responding 2024-04-07 23:12:46.798 DEBUG (MainThread) [pymodbus.logging] callback_disconnected called: Server not responding

@janiversen
Copy link
Member

janiversen commented Apr 8, 2024

Yes something is going on clearly, as you can see in the log your device is not responding

The "not ready frame" is something else which I will look at.

@crug80
Copy link
Contributor

crug80 commented Apr 8, 2024

Maybe the "not ready frame" is part of reason why device is not responding.. All my devices are up and no problems after the rollback to 2024.3.3.

@janiversen
Copy link
Member

the "not ready frame" will cause setting the entity to unavialable, I am still looking into why it happens.

Funny thing is that between 2024.3.3 and 2024.4.0 pymodbus is unchanged, what changed basically is that the transport level is not async, but decoding of the modbus packages etc are the same. So somewhere within that change set is something that do not work correctly.

@pupsette
Copy link

pupsette commented Apr 8, 2024

Hi, I just want to mention that I encountered the exact same issue (most likely) with 2024.04 and my modbus configuration. Multiple restarts and other attempts did not fix it. Rollback to 2024.3.3 solved the issue instantly.

@mjunker61
Copy link

mjunker61 commented Apr 8, 2024

Me Too. Only Rollback to 2024.3.3 solved IT !

@janiversen
Copy link
Member

@pupsette and @mjunker61 the "me too" movement does not live well here, we help people who try to help themself. Did you read the release notes, there was a breaking note change, that modbus changed to async and it might cause problems.

@rostislav-palivoda
Copy link

Modbus Error: [Connection] Not connected[AsyncModbusSerialClient /dev/ttyUSB0:0]

Is it possible to switch back to sync modbus client?

2024-04-08 21:04:01.027 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: modbus0: Error: device: 3 address: 6 -> Modbus Error: [Input/Output] ERROR: No response received after 3 retries
2024-04-08 21:04:01.028 DEBUG (MainThread) [pymodbus.logging] Wait comm 100.0 ms before reconnecting.
2024-04-08 21:04:01.088 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: modbus0: Error: device: 3 address: 7 -> Modbus Error: [Connection] Not connected[AsyncModbusSerialClient /dev/ttyUSB0:0]
2024-04-08 21:04:01.129 DEBUG (MainThread) [pymodbus.logging] Connecting to /dev/ttyUSB0.
2024-04-08 21:04:01.129 DEBUG (MainThread) [pymodbus.logging] Connecting comm
2024-04-08 21:04:01.134 DEBUG (MainThread) [pymodbus.logging] Connected to comm
2024-04-08 21:04:01.150 DEBUG (MainThread) [pymodbus.logging] Adding transaction 3
2024-04-08 21:04:01.150 DEBUG (MainThread) [pymodbus.logging] send: 0x3 0x3 0x0 0x8 0x0 0x1 0x4 0x2a
2024-04-08 21:04:01.163 DEBUG (MainThread) [pymodbus.logging] recv: 0x3 0x3 0x2 old_data:  addr=None
2024-04-08 21:04:01.164 DEBUG (MainThread) [pymodbus.logging] Processing: 0x3 0x3 0x2
2024-04-08 21:04:01.164 DEBUG (MainThread) [pymodbus.logging] Frame - not ready
2024-04-08 21:04:01.179 DEBUG (MainThread) [pymodbus.logging] recv: 0x0 0x0 0xc1 0x84 old_data:  addr=None
2024-04-08 21:04:01.180 DEBUG (MainThread) [pymodbus.logging] Processing: 0x0 0x0 0xc1 0x84
2024-04-08 21:04:01.180 DEBUG (MainThread) [pymodbus.logging] Frame - not ready
2024-04-08 21:04:01.651 DEBUG (MainThread) [pymodbus.logging] Adding transaction 3
2024-04-08 21:04:01.651 DEBUG (MainThread) [pymodbus.logging] send: 0x3 0x3 0x0 0x8 0x0 0x1 0x4 0x2a
2024-04-08 21:04:01.675 DEBUG (MainThread) [pymodbus.logging] recv: 0x3 0x3 0x2 0x0 0x0 0xc1 0x84 old_data:  addr=None
2024-04-08 21:04:01.675 DEBUG (MainThread) [pymodbus.logging] Processing: 0x3 0x3 0x2 0x0 0x0 0xc1 0x84
2024-04-08 21:04:01.675 DEBUG (MainThread) [pymodbus.logging] Frame - not ready
2024-04-08 21:04:02.152 DEBUG (MainThread) [pymodbus.logging] Adding transaction 3
2024-04-08 21:04:02.152 DEBUG (MainThread) [pymodbus.logging] send: 0x3 0x3 0x0 0x8 0x0 0x1 0x4 0x2a
2024-04-08 21:04:02.171 DEBUG (MainThread) [pymodbus.logging] recv: 0x3 0x3 0x2 0x0 0x0 0xc1 0x84 old_data:  addr=None
2024-04-08 21:04:02.171 DEBUG (MainThread) [pymodbus.logging] Processing: 0x3 0x3 0x2 0x0 0x0 0xc1 0x84
2024-04-08 21:04:02.171 DEBUG (MainThread) [pymodbus.logging] Frame - not ready
2024-04-08 21:04:02.653 DEBUG (MainThread) [pymodbus.logging] Adding transaction 3
2024-04-08 21:04:02.653 DEBUG (MainThread) [pymodbus.logging] send: 0x3 0x3 0x0 0x8 0x0 0x1 0x4 0x2a
2024-04-08 21:04:02.666 DEBUG (MainThread) [pymodbus.logging] recv: 0x3 0x3 old_data:  addr=None
2024-04-08 21:04:02.666 DEBUG (MainThread) [pymodbus.logging] Processing: 0x3 0x3
2024-04-08 21:04:02.667 DEBUG (MainThread) [pymodbus.logging] Frame - not ready
2024-04-08 21:04:02.682 DEBUG (MainThread) [pymodbus.logging] recv: 0x2 0x0 0x0 0xc1 0x84 old_data:  addr=None
2024-04-08 21:04:02.682 DEBUG (MainThread) [pymodbus.logging] Processing: 0x2 0x0 0x0 0xc1 0x84
2024-04-08 21:04:02.682 DEBUG (MainThread) [pymodbus.logging] Frame - not ready
2024-04-08 21:04:03.154 DEBUG (MainThread) [pymodbus.logging] Connection lost comm due to Server not responding
2024-04-08 21:04:03.158 DEBUG (MainThread) [pymodbus.logging] callback_disconnected called: Server not responding
2024-04-08 21:04:03.158 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: modbus0: Error: device: 3 address: 8 -> Modbus Error: [Input/Output] ERROR: No response received after 3 retries

@Gnarfoz
Copy link

Gnarfoz commented Apr 8, 2024

Not sure if you're trying to drag the actual #MeToo movement through the mud here, but these are just desperate users whose setups broke.
Perhaps due to a change that was only listed in the "full changelog" (which probably nobody reads), wasn't part of the blog post change log (which they might have read), and wasn't listed under the "backwards-incompatible changes". (Home Assistant does not have "breaking changes" anymore).
Even if they had read it, and seen that particular change, how would that have helped them or anyone else?
They did the obvious thing and rolled back to a working version and added their comment to underline that this doesn't affect just one user.

@rostislav-palivoda There is no toggle, you can only downgrade to 2024.3.

Does this change to async library calls affect ordering and/or pacing of Modbus requests at all?
There are various vendors who use very fickle Modbus implementations that can be broken just by making overlapping requests or multiple connections (looking at for example Sungrow and SolarEdge).
I'd guess no, but guessing doesn't really help here. ;-)

@rostislav-palivoda
Copy link

rostislav-palivoda commented Apr 8, 2024

Downgraded from 2024.4.2 to 2024.3.3. Modbus works.

@janiversen
Copy link
Member

I am a big fan of the #MeToo movement, just not when it is misused to complain and offer no help to solve the problem.

If you look in pull request #113450
you will see it is clearly marked as a "Breaking change", with a warning, that the release might be unstable, that is what I can do as developer to warn users, if that is not translated into user information then maybe you should file an issue elsewhere.

The change to async do not affect the ordering/packing, and if you look carefully the library for 2024.3.3 and 2024.4.0 is the same...but since the code is faster shorter disconnects are now detected, which is correct...and there are some problem with the decoding of the packages, which is being investigated.

As you say guessing do not help, apart from the fact that all these messages reduces the time I have to find the real problem.

@janiversen
Copy link
Member

Analyzed and isolated modbus problems

The analysis is added to #115236, which you can follow to see the progress, but PLEASE do not comment there, as it only makes it more difficult to solve the problems.

Closing issue, Bug fixing will happen on #115236

@jayjayvm
Copy link

jayjayvm commented Apr 27, 2024

I read the change tekst it did not make sense to me, plus I try to keep up with the changes, for it might be the best. That said, my SMA Inverter via MODBUS is gone too, no values any-more. It is easy for people who understand it all to say read the changes, and then you should have known, or it is an easy fix. But for many it is not, and they end up with a broken entity or device. I would appreciate help on this issue, but I am afraid someone with much more insight will tell me, do your homework, sorry you are so dumb, and do not waste our time, for that is where we are these days in the HA community.

@janiversen
Copy link
Member

Surely your rant is not the way to get help, but I cleared your ches5 to get it out. Please remember this is not a support forum! we only care about bugs in the product.

Anyhow we made 2024.4.3 for a reason so feel free to try it.

@jayjayvm
Copy link

jayjayvm commented Apr 27, 2024

Dear Jan, I do see this as a bug to be honest. And it is not the first time an option previously working fine does a great disappearance, cause of a decision someone takes somewhere for whatever reason. Yes it gives a lot of people frustrations, me too, look in the forum and you see a lot of people trying to fix this newly made BUG. And I so often got answered in a vinegar pissing way as something went awry, sorry that I started in this tone, but this is probably the 5th integration that went belly up in HA for me, I always asked nicely how to solve it and has always been met with answers like this is not a help topic, this is not for beginners, did you read the breaking news and other nasty ways, developers like to answer me, so I am truly sorry to have started this way, BUT I hope you know how to fix this, even though it is not a support forum.
I do not like to do a back install and stay there for years, I like a solution, and so many in the forum do.

How do we fix this?

I use core 2024.4.4 now and that is when my MODBUS gave out. SO I will not downgrade to 2024.4.3

@janiversen
Copy link
Member

First of all you write on a closed issue, and nothing more happens on this issue

Secondly you do not follow the guidelines on how to report a bug, we are not magicians we cannot determine/solve a bug without detailed

Thirdly we do not provide help here, that is done in the forum.

Have a nice day.

@e6on
Copy link
Author

e6on commented Apr 29, 2024

Hello, just wanted to let you know (because I'm the one who created this bug ticket) that after upgading to 2024.4.4 five days ago I do not have any connection problems and I have only 2 modbus errors in the log form the first day of upgrading to 2024.4.4

Logger: homeassistant.components.modbus.modbus
Source: components/modbus/modbus.py:318
integration: Modbus ([documentation](https://www.home-assistant.io/integrations/modbus), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+modbus%22))
First occurred: April 24, 2024 at 22:52:35 (2 occurrences)
Last logged: April 25, 2024 at 07:03:53

Pymodbus: komfovent: Error: device: 0 address: 940 -> pymodbus returned isError True
Pymodbus: komfovent: Error: device: 0 address: 901 -> Modbus Error: [Input/Output] ERROR: No response received after 3 retries

So I guess all good from my side.
Thank you Jan.

@github-actions github-actions bot locked and limited conversation to collaborators May 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants