Skip to content

Conversation

@vasileio
Copy link

@vasileio vasileio commented Nov 5, 2025

Description
Fix KeyError in shelly_gen2 power_get() function due to incorrect JSON response parsing.  The current implementation attempts to access response["output"] directly, but the Shelly Gen 2 RPC API returns the output field nested inside a result object.

API Response Structure:

{
  "id": 1,
  "result": {
    "output": true,
    "apower": 0.0,
    "voltage": 245.3
  }
}

Fix:
Change r.json()["output"] to r.json()["result"]["output"] in line 30.

Testing:

  • Verified with Shelly Plus Plug UK device
  • All power operations (get/set/cycle) now work correctly
  • Compatible with existing NetworkPowerPort configurations

Checklist

  • Tests for the feature
  • PR has been tested

Fix KeyError in shelly_gen2 power_get() function due to incorrect JSON response parsing.

Signed-off-by: Vasileios Bimpikas <[email protected]>
@Emantor
Copy link
Member

Emantor commented Nov 5, 2025

@aparcar please take a look.

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.

2 participants