Skip to content

Fehler bei Phasenanzahl bei Shelly 3EM-63 Gen3#3132

Open
Pendragon77 wants to merge 5 commits intoopenWB:masterfrom
Pendragon77:patch-2
Open

Fehler bei Phasenanzahl bei Shelly 3EM-63 Gen3#3132
Pendragon77 wants to merge 5 commits intoopenWB:masterfrom
Pendragon77:patch-2

Conversation

@Pendragon77
Copy link
Contributor

Basierend auf folgendem Problemreport:

Forum

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.
@LKuemmel LKuemmel requested a review from ndrsnhs February 10, 2026 07:03
Anpassung an den Vorschlag von ndrsnhs. Ist einfacher...
Copy link
Contributor Author

@Pendragon77 Pendragon77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hast recht. Das sollte einfacher sein

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 of range(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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants