You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It took me quite a while to understand the origin but after some users posted the back trace, I could reproduce it.
The problem
Randomly, the add-on stop working, as reported by multiple user. A user posted a stack trace:
File "/app/grottproxy.py", line 238, in on_recv
procdata(conf,data)
^^^^^^^^^^^^^^^^^^^
File "/app/grottdata.py", line 220, in procdata
for keyword in conf.recorddict[layout].keys() :
~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'T06NNNNMIN'
Minimal reproduction
Requirements
1 data packet with a known serial inverter
grott.int
[Generic]invtypemap = {"INVERTERSERIAL": "TES"}
Procedure
Start grott with the ini
Send the data packet.
The cause
When the invtypemap, grott compose the layout from the packet type: e.g T06NNNN then add the prefix found in the dict invtypemap.
There is a layout for T06NNNNXMIN which is the nominal case, but sporadically, the inverter sends a shorter packet.
In this case, the if ((ndata > 375) is false and the 'X' is not appended.
This generates a layout T06NNNNMIN, which doesn't exist (unlike the T06NNNNXMIN).
grottdata.py:220 trust blindly the layout will be present and crash grott.
A way to solve this is to check before doing conf.recorddict[layout] by using a if layout not in conf.recorddict
Patch
I made a quick patch which skips the layout parsing if the layout doesn't exist. I'm going to see If I can generate a MR
Index: grottdata.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================diff --git a/grottdata.py b/grottdata.py--- a/grottdata.py (revision f52ece051b17efd4a1f57fa8a3e0d6cfeca5adf5)+++ b/grottdata.py (date 1721649080279)@@ -198,15 +198,19 @@
# Update the conf.layout like done earlier
conf.layout = layout
+ layout_exists = layout in conf.recorddict+
if conf.verbose:
print("\t - " + 'Growatt new layout processing')
print("\t\t - " + "decrypt : ",conf.decrypt)
print("\t\t - " + "offset : ", conf.offset)
print("\t\t - " + "record layout : ", layout)
+ print("\t\t - " + "layout exists : ", layout_exists)
print()
--+ if not layout_exists:+ return # No valid layout found, no further processing+
try:
#v270 try if logstart and log fields are defined, if yes prepare log fields
logstart = conf.recorddict[layout]["logstart"]["value"]
Regards
The text was updated successfully, but these errors were encountered:
Hi, I maintain a grott add-on for HA and I have multiple user reporting a crash.
bug ref: egguy/addon-grott#32
It took me quite a while to understand the origin but after some users posted the back trace, I could reproduce it.
The problem
Randomly, the add-on stop working, as reported by multiple user. A user posted a stack trace:
Minimal reproduction
Requirements
grott.int
Procedure
The cause
When the
invtypemap
, grott compose the layout from the packet type: e.gT06NNNN
then add the prefix found in the dictinvtypemap
.There is a layout for
T06NNNNXMIN
which is the nominal case, but sporadically, the inverter sends a shorter packet.In this case, the
if ((ndata > 375)
is false and the 'X' is not appended.This generates a layout
T06NNNNMIN
, which doesn't exist (unlike theT06NNNNXMIN
).grottdata.py:220
trust blindly the layout will be present and crash grott.A way to solve this is to check before doing
conf.recorddict[layout]
by using aif layout not in conf.recorddict
Patch
I made a quick patch which skips the layout parsing if the layout doesn't exist. I'm going to see If I can generate a MR
Regards
The text was updated successfully, but these errors were encountered: