Shelly: add missing PM1 condition (#20919)

This commit is contained in:
Markus Thierolf 2025-04-28 11:48:50 +02:00 • committed by GitHub
parent 3b7680f256
commit 5eff3d995a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {