From 5eff3d995a3db329e3610006b6efd32dc593d379 Mon Sep 17 00:00:00 2001 From: Markus Thierolf <77847348+thierolm@users.noreply.github.com> Date: Mon, 28 Apr 2025 11:48:50 +0200 Subject: [PATCH] Shelly: add missing PM1 condition (#20919) --- meter/shelly/gen2.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/meter/shelly/gen2.go b/meter/shelly/gen2.go index d5e6dbde8..787b38600 100644 --- a/meter/shelly/gen2.go +++ b/meter/shelly/gen2.go @@ -116,7 +116,7 @@ func newGen2(helper *request.Helper, uri, model string, channel int, user, passw c.methods = res.Methods - if c.hasPM1Endpoint() { + if c.hasMethod("PM1.GetStatus") { c.switchstatus = util.ResettableCached(apiCall[Gen2SwitchStatus](c, "PM1.GetStatus"), cache) } else { c.switchstatus = util.ResettableCached(apiCall[Gen2SwitchStatus](c, "Switch.GetStatus"), cache) @@ -265,11 +265,7 @@ func (c *gen2) Powers() (float64, float64, float64, error) { // Gen2+ models using Switch.GetStatus endpoint https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Switch#switchgetstatus-example func (c *gen2) hasSwitchEndpoint() bool { - return c.hasMethod("Switch.GetStatus") -} - -func (c *gen2) hasPM1Endpoint() bool { - return c.hasMethod("PM1.GetStatus") + return c.hasMethod("Switch.GetStatus") || c.hasMethod("PM1.GetStatus") } func (c *gen2) hasEM1Endpoint() bool {