Closed SonnyBBQ closed 1 week ago
Same issue here
Same issue here, I have to reset the inverter to make the modbus connection working for a limited time.
Is anyone able to label this issue?
Adding the link didn't work:
Link to integration documentation on our website https://www.home-assistant.io/integrations/modbus/
I tried your code on HA 2024.5.1 but it all works fine. I know if a SMA inverter is too busy it can block traffic (maybe you also readout with webconnect?)
Maybe you can try to add delays to the modbus command:
modbus:
- name: SMA
type: tcp
host: 192.168.1.223 #fixed ip in SMA 192.168.1.223
port: 502
delay: 5
message_wait_milliseconds: 600
timeout: 5
Thanks for thinking along. I did already try the delay and eventually it will stop working as well (I can do that again and add the logs, but it didn't show anything different). Even with the set-up shared in the original post, it works fine, but only for a limited time.
My modbus set-up has been running for years without issue. Nothing was changed on the inverter side. So something else must have caused the issue. And it happened when updating to 2024.4.
Might want to try with node-red to see if the SMA is not the problem? https://gathering.tweakers.net/forum/list_message/77883380#77883380
https://github.com/fonske/SMA_inverter_logging/tree/main/Node-red_flows
Hey there @janiversen, mind taking a look at this issue as it has been labeled with an integration (modbus
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
modbus documentation modbus source (message by IssueLinks)
This is NOT a bug, you are using a template, but have forgotten that the sensor value can be "unavailable" and thus not possible to convert to a float. The modbus integration (like most other integrations) set a sensor to a value when available but to "unavailable" when not available, actually quite logical.
Please correct your template sensor, to respond correctly if the value of the sensor is "unavailable".
I do however have a feeling that a number of the "@metoo" are actually referring to a different problem, if that is the case they should open an issue with a proper debug.log as pr modbus integration (remember to shorten the log, to show a couple of minutes before and after the problem).
Hi @janiversen you are right, I should have shortened my debug log indeed. Fully aware that my template sensors can be unavailable. That's not the problem for me and is expected. And I have designed my dashboard around that with conditional cards ... but that's offtopic.
The problem is that the modbus connection to my SMA inverter loses connection after a few hours. This started happening after updating to 2024.4. I had been using the Modbus integration (not the SMA integration) in it's current configuration for years and it has been super stable. So I would love to get this back up and running.
Per @ebbenberg comments. I am not using other connections to the SMA (no webconnect) and have already tried the delays, including the above proposed delays, which are way longer than suggested by SMA.
Also nothing changed on the SMA site, no firmware update or anything.
I have restarted both the inverter and HA again and will add a new log when the issue arises in a few hours. Hopefully that will give you the necessary to investigate.
Hi @janiversen , so the Modbus connection worked since I had activated it 4 days ago and stopped again yesterday.
This is a snippet of the log - hope it helps:
2024-05-15 13:21:18.963 DEBUG (MainThread) [pymodbus.logging] Connecting to 192.168.1.223:502.
2024-05-15 13:21:18.963 DEBUG (MainThread) [pymodbus.logging] Connecting comm
2024-05-15 13:21:18.970 DEBUG (MainThread) [pymodbus.logging] Connected to comm
2024-05-15 13:21:18.970 DEBUG (MainThread) [pymodbus.logging] Resetting frame - Current Frame in buffer -
2024-05-15 13:21:18.970 INFO (MainThread) [homeassistant.components.modbus.modbus] modbus SMA communication open
2024-05-15 13:21:36.648 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1
2024-05-15 13:21:36.648 DEBUG (MainThread) [pymodbus.logging] Resetting frame - Current Frame in buffer -
2024-05-15 13:21:36.648 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x1 0x0 0x0 0x0 0x6 0x3 0x3 0x78 0x37 0x0 0x2
2024-05-15 13:21:36.803 DEBUG (MainThread) [pymodbus.logging] recv: 0x0 0x1 0x0 0x0 0x0 0x7 0x3 0x3 0x4 0x0 0x0 0x1 0x96 old_data: addr=None
2024-05-15 13:21:36.803 DEBUG (MainThread) [pymodbus.logging] Processing: 0x0 0x1 0x0 0x0 0x0 0x7 0x3 0x3 0x4 0x0 0x0 0x1 0x96
2024-05-15 13:21:36.803 DEBUG (MainThread) [pymodbus.logging] Factory Response[ReadHoldingRegistersResponse': 3]
2024-05-15 13:21:36.803 DEBUG (MainThread) [pymodbus.logging] Getting transaction 1
2024-05-15 13:21:36.804 DEBUG (MainThread) [pymodbus.logging] Frame check, no more data!
2024-05-15 13:21:37.416 DEBUG (MainThread) [pymodbus.logging] Adding transaction 2
2024-05-15 13:21:37.416 DEBUG (MainThread) [pymodbus.logging] Resetting frame - Current Frame in buffer -
2024-05-15 13:21:37.416 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x2 0x0 0x0 0x0 0x6 0x3 0x3 0x77 0x35 0x0 0x4
2024-05-15 13:21:37.553 DEBUG (MainThread) [pymodbus.logging] recv: 0x0 0x2 0x0 0x0 0x0 0xb 0x3 0x3 0x8 0x0 0x0 0x0 0x0 0x0 0x0 0x10 old_data: addr=None
2024-05-15 13:21:37.553 DEBUG (MainThread) [pymodbus.logging] Processing: 0x0 0x2 0x0 0x0 0x0 0xb 0x3 0x3 0x8 0x0 0x0 0x0 0x0 0x0 0x0 0x10
2024-05-15 13:21:37.554 DEBUG (MainThread) [pymodbus.logging] Frame check failed, missing part of message len 16, MBAP len 11 !!
2024-05-15 13:21:37.554 DEBUG (MainThread) [pymodbus.logging] recv: 0x13 old_data: addr=None
2024-05-15 13:21:37.554 DEBUG (MainThread) [pymodbus.logging] Processing: 0x0 0x2 0x0 0x0 0x0 0xb 0x3 0x3 0x8 0x0 0x0 0x0 0x0 0x0 0x0 0x10 0x13
2024-05-15 13:21:37.554 DEBUG (MainThread) [pymodbus.logging] Factory Response[ReadHoldingRegistersResponse': 3]
2024-05-15 13:21:37.554 DEBUG (MainThread) [pymodbus.logging] Getting transaction 2
2024-05-15 13:21:37.554 DEBUG (MainThread) [pymodbus.logging] Frame check, no more data!
2024-05-15 13:21:38.157 DEBUG (MainThread) [pymodbus.logging] Adding transaction 3
2024-05-15 13:21:38.157 DEBUG (MainThread) [pymodbus.logging] Resetting frame - Current Frame in buffer -
2024-05-15 13:21:38.157 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x3 0x0 0x0 0x0 0x6 0x3 0x3 0x77 0x31 0x0 0x4
2024-05-15 13:21:38.298 DEBUG (MainThread) [pymodbus.logging] recv: 0x0 0x3 0x0 0x0 0x0 0xb 0x3 0x3 0x8 0x0 0x0 0x0 0x0 0x1 0x5e 0x85 old_data: addr=None
2024-05-15 13:21:38.298 DEBUG (MainThread) [pymodbus.logging] Processing: 0x0 0x3 0x0 0x0 0x0 0xb 0x3 0x3 0x8 0x0 0x0 0x0 0x0 0x1 0x5e 0x85
2024-05-15 13:21:38.298 DEBUG (MainThread) [pymodbus.logging] Frame check failed, missing part of message len 16, MBAP len 11 !!
2024-05-15 13:21:38.299 DEBUG (MainThread) [pymodbus.logging] recv: 0x45 old_data: addr=None
2024-05-15 13:21:38.299 DEBUG (MainThread) [pymodbus.logging] Processing: 0x0 0x3 0x0 0x0 0x0 0xb 0x3 0x3 0x8 0x0 0x0 0x0 0x0 0x1 0x5e 0x85 0x45
2024-05-15 13:21:38.299 DEBUG (MainThread) [pymodbus.logging] Factory Response[ReadHoldingRegistersResponse': 3]
2024-05-15 13:21:38.299 DEBUG (MainThread) [pymodbus.logging] Getting transaction 3
2024-05-15 13:21:38.299 DEBUG (MainThread) [pymodbus.logging] Frame check, no more data!
2024-05-15 13:21:38.910 DEBUG (MainThread) [pymodbus.logging] Adding transaction 4
2024-05-15 13:21:38.910 DEBUG (MainThread) [pymodbus.logging] Resetting frame - Current Frame in buffer -
2024-05-15 13:21:38.911 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x4 0x0 0x0 0x0 0x6 0x3 0x3 0x78 0x3f 0x0 0x2
2024-05-15 13:21:39.053 DEBUG (MainThread) [pymodbus.logging] recv: 0x0 0x4 0x0 0x0 0x0 0x7 0x3 0x3 0x4 0x0 0x0 0x5a old_data: addr=None
2024-05-15 13:21:39.053 DEBUG (MainThread) [pymodbus.logging] Processing: 0x0 0x4 0x0 0x0 0x0 0x7 0x3 0x3 0x4 0x0 0x0 0x5a
2024-05-15 13:21:39.054 DEBUG (MainThread) [pymodbus.logging] Frame check failed, missing part of message len 12, MBAP len 7 !!
2024-05-15 13:21:39.055 DEBUG (MainThread) [pymodbus.logging] recv: 0xda old_data: addr=None
2024-05-15 13:21:39.055 DEBUG (MainThread) [pymodbus.logging] Processing: 0x0 0x4 0x0 0x0 0x0 0x7 0x3 0x3 0x4 0x0 0x0 0x5a 0xda
2024-05-15 13:21:39.055 DEBUG (MainThread) [pymodbus.logging] Factory Response[ReadHoldingRegistersResponse': 3]
2024-05-15 13:21:39.055 DEBUG (MainThread) [pymodbus.logging] Getting transaction 4
2024-05-15 13:21:39.055 DEBUG (MainThread) [pymodbus.logging] Frame check, no more data!
2024-05-15 13:21:39.658 DEBUG (MainThread) [pymodbus.logging] Adding transaction 5
2024-05-15 13:21:39.658 DEBUG (MainThread) [pymodbus.logging] Resetting frame - Current Frame in buffer -
2024-05-15 13:21:39.658 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x5 0x0 0x0 0x0 0x6 0x3 0x3 0x78 0x53 0x0 0x2
2024-05-15 13:21:39.798 DEBUG (MainThread) [pymodbus.logging] recv: 0x0 0x5 0x0 0x0 0x0 0x7 0x3 0x3 0x4 0x0 0x0 0x13 old_data: addr=None
2024-05-15 18:28:00.689 DEBUG (MainThread) [pymodbus.logging] Connection lost comm due to Server not responding
2024-05-15 18:28:00.690 DEBUG (MainThread) [pymodbus.logging] callback_disconnected called: Server not responding
2024-05-15 18:28:00.690 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30775 -> Modbus Error: [Input/Output] ERROR: No response received after 3 retries
2024-05-15 18:28:00.693 DEBUG (MainThread) [pymodbus.logging] Wait comm 100.0 ms before reconnecting.
2024-05-15 18:28:00.794 DEBUG (MainThread) [pymodbus.logging] Connecting to 192.168.1.223:502.
2024-05-15 18:28:00.794 DEBUG (MainThread) [pymodbus.logging] Connecting comm
Your device is not responding, last entry shows modbus trying to reconnect, this have nothing to do with the modbus integration
But what else could be causing this? As said, I have been running this for years without issue. These problems happened exactly at the same time as the upgrade to Home Assistant Core 2024.4. I realize coincidences do exist, but there were no other changes to the hardware or firmware of the SMA, neither to my network. Could it be a change in the Modbus communication which makes the SMA block/drop the connection? ANy other thoughts re troubleshooting this?
This is a channel for reporting bug, not making support, please use the user forums.
It is a bug for me. Never happened before. Even though the debug log does not state anything when connected there must be something regarding establishing the connection.
I had referenced this in issue #116289 as well, but since that was closed, opening as a new issue.
The Modbus connection to SMA no longer works since upgrading to 2024.4. I'm currently on 2024.5 and the issue persists.
What version of Home Assistant Core has the issue? 2024.4 onwards
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 Modbus
Link to integration documentation on our website https://www.home-assistant.io/integrations/modbus/
Diagnostics information No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information Resetting the inverter will make the connection work for a limited time only. Couple hours at most.
Originally posted by @SonnyBBQ in https://github.com/home-assistant/core/issues/116289#issuecomment-2084569884