Fehler bei Phasenanzahl bei Shelly 3EM-63 Gen3#3132
Fehler bei Phasenanzahl bei Shelly 3EM-63 Gen3#3132Pendragon77 wants to merge 5 commits intoopenWB:masterfrom
Conversation
Bei Shelly 3EM-63 Gen3 ist len(meters) nicht die Anzahl der Phasen sondern die Gesamtlänge der Mesergebnisse und somit viel zu groß
Begrenzung auf 3 Phasen
Autobuild hat die verwaiste Variable gefunden.
Anpassung an den Vorschlag von ndrsnhs. Ist einfacher...
Pendragon77
left a comment
There was a problem hiding this comment.
Hast recht. Das sollte einfacher sein
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the Shelly inverter module where the phase count iteration was incorrect for the Shelly Pro3EM Gen2/Gen3 devices. The issue occurred because the em:0 status data is returned as a dictionary with many keys (not just the 3 phases), and using range(len(meters)) would iterate over all dictionary keys instead of just the three phases (a, b, c).
Changes:
- Fixed phase iteration for Shelly Pro3EM devices in inverter module by using
range(0, 3)instead ofrange(len(meters))
Comments suppressed due to low confidence (1)
packages/modules/devices/shelly/shelly/inverter.py:72
- The inverter module lacks test coverage for the Shelly Pro3EM device (generation 2), which would have caught this bug. The counter tests include Pro3EM test cases (lines 177-191 in shelly_test.py) but the inverter tests (lines 257-282) skip this device model entirely. Consider adding Pro3EM test cases to the inverter test suite using the existing DATA_PRO_3EM_G2 test data to prevent similar issues in the future.
elif "em:0" in status:
meters = status['em:0']
for i in range(0, 3):
if meters.get(f'{alphabetical_index[i]}_current') is None:
continue
currents[(i+self.phase-1) % 3] = (float(meters[f'{alphabetical_index[i]}_current']) * self.factor
if meters.get(f'{alphabetical_index[i]}_current') else 0)
power = float(meters['total_act_power']) * self.factor
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Ich habe nochmal etwas über Deinen PR nachgedacht, es gibt im Shelly-Modul ja noch einige ähnliche Stellen, an denen es auch zu Problemen kommen kann. Ich denke mit #3179 sind nun alle Fälle abgedeckt. |
Basierend auf folgendem Problemreport:
Forum