Skip to content

Commit

Permalink
Fixed having wrong zaehlpunkt with multi contracts
Browse files Browse the repository at this point in the history
When adding or updating a sensor, the zaehlpunkt is checked with the get_zaehlpunkt function. The problem was that the variable for the array, which has the zaehlpunkt details in them, had the same name as the zaehlpunkt itself.
So when having multiple contracts/customerIds, the correct zaehlpunkt was overwritten by the zaehlpunkt details, which is now an empty array. All API requests were then done with an empty array and threw errors all around.
  • Loading branch information
tschoerk authored and DarwinsBuddy committed Nov 12, 2024
1 parent ef0b6ff commit 0607121
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/wnsm/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ def get_zaehlpunkt(self, zaehlpunkt: str = None) -> tuple[str, str, str]:
else:
customer_id = zp = anlagetype = None
for contract in contracts:
zp = [z for z in contract["zaehlpunkte"] if z["zaehlpunktnummer"] == zaehlpunkt]
if len(zp) > 0:
anlagetype = zp[0]["anlage"]["typ"]
zp = zp[0]["zaehlpunktnummer"]
zp_details = [z for z in contract["zaehlpunkte"] if z["zaehlpunktnummer"] == zaehlpunkt]
if len(zp_details) > 0:
anlagetype = zp_details[0]["anlage"]["typ"]
zp = zp_details[0]["zaehlpunktnummer"]
customer_id = contract["geschaeftspartner"]
return customer_id, zp, const.AnlageType.from_str(anlagetype)

Expand Down

0 comments on commit 0607121

Please sign in to comment.