-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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 integration sometimes reports excessive values #119649
Comments
Hey there @janiversen, 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 |
Frame check failed means the packet is dropped, no further processing, so your problem is something else, I will investigate |
In need a more complete debug log, the couple of lines you have provided does not show a problem. |
your device duplicates the response: Apart from that the value is 934332, which seems very high. So to sum up, analyzing your log, it looks as if your device sends 2 responses, and the second one overlaps the first. |
ooh and btw with tcp/ip the cables are not the cause....unless of course HA connect to a rs485 converter, in which case the converter could have a problem. |
Here's the full log: debug-log.gz TCP/IP should indeed prevent transmission errors. There's no converter involved, just plain old ModbusTCP + TCP/IP over Ethernet. Is it possible this is a case of "after switching to async calls, more stuff is caught that would have previously never been visible"? |
No this have nothing to do with the change to async. The library below the modbus integration prints what it receives, maybe your device sends double packets....you need to check that with Wireshark or a similar tool that sniffs on the ethernet. I cannot tell you why/where the duplicate packet originates, but I see modbus handling it correctly, value of first packet is set in the entity (although with a high value, due to the duplication), and the second packet is discarded. |
Odd, nothing but HA versions changed in the mean time, so of course, the suspicion falls there. ;-) |
Any new findings ? if not this will be closed as solved. |
Hey, sorry for the delay. I had successfully captured an instance of this happening, but wasn't sure how to further interpret the data. The issue occurs at 2024-06-27 23:19:36.725 (timestamps match between packet capture and HA log). I'm still not sure where that leaves us. Is this something that's unfixable? |
Nice analysis, I will examine it in detail and I expect I at least should be able to see where the problem originates. I really wish others would do a similar thorough analysis, instead of just yelling "there is a problem". |
Closing as this is clearly not a bug in any home assistant component, but in the device. Thanks again for a very useful analysis. |
Thank you for narrowing it down, @janiversen! 👍 I'll have to live with* setting realistic Would you be open to extending the logic of __process_raw_value to optionally return *) Its unlikely I'll be able to get this problem noticed by the right people via the device manufacturer's customer support. 🤷♂️ |
Setting max/min sounds wrong to me....a more logical approach (but more complicated) is to make a template sensor, that compare the received value against a variable and only permit x% deviation...once compared the variable is updated with the new value. This as well as your suggestion is something general, that should not be implemented in every integration but centrally. |
Using Templating every sensor I'm reading through Modbus indeed sounds more complicated... Maybe I should try creating a "range_discard" filter that does almost what the range filter does but returns the Either way, new avenues to explore and not something this particular integration can resolve. :-) |
The problem
A couple of times a day I get a wildly excessive value for a (mostly?) random Modbus sensor. Excessive meaning values being in the millions or billions for things that are supposed to be in the thousands or tens of thousands. Things like power usage in Gigawatts. Negative and positive values are affected.
At first I thought it was a one-off thing, then I blamed badly shielded network cables. It keeps happening now, and I've changed cables as well. I've also come across reports from other people, so it's unlikely to be caused by something specific to my setup.
Firmware on the involved devices is the same as before this behavior started appearing.
The debug log I've gathered over 24 hours includes it happening twice to the same sensor and once to another sensor.
For context purposes, I've included 2 transactions before and after each occurrence.
For comparison purposes, I've included a "good" and a "bad" transaction for each occurrence.
It is obvious that for the bad transactions, the response is quite a bit longer than for the good transactions.
What version of Home Assistant Core has the issue?
core-2024.6.2
What was the last working version of Home Assistant Core?
March or April 2024
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Modbus
Link to integration documentation on our website
https://www.home-assistant.io/integrations/modbus/
Diagnostics information
debug.log
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
I've resorted to sprinkling a generous amount of
max_value
/min_value
properties across my configuration, to at least limit the impact on long term statistics and make history graphs usable again. (One of these excessive values in a history graph dwarfs everything).In some cases, that's not practical (ever-increasing "total" sensors that will at some point reach those limits). Also,
max_value
andmin_value
force the excessive value to the defined limit, thus affecting statistics.IMHO frames that failed such checks should be dropped from further processing, no?
The text was updated successfully, but these errors were encountered: