Skip to content

Commit 5eff3d9

Browse files
authored
Shelly: add missing PM1 condition (#20919)
1 parent 3b7680f commit 5eff3d9

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

meter/shelly/gen2.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func newGen2(helper *request.Helper, uri, model string, channel int, user, passw
116116

117117
c.methods = res.Methods
118118

119-
if c.hasPM1Endpoint() {
119+
if c.hasMethod("PM1.GetStatus") {
120120
c.switchstatus = util.ResettableCached(apiCall[Gen2SwitchStatus](c, "PM1.GetStatus"), cache)
121121
} else {
122122
c.switchstatus = util.ResettableCached(apiCall[Gen2SwitchStatus](c, "Switch.GetStatus"), cache)
@@ -265,11 +265,7 @@ func (c *gen2) Powers() (float64, float64, float64, error) {
265265

266266
// Gen2+ models using Switch.GetStatus endpoint https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Switch#switchgetstatus-example
267267
func (c *gen2) hasSwitchEndpoint() bool {
268-
return c.hasMethod("Switch.GetStatus")
269-
}
270-
271-
func (c *gen2) hasPM1Endpoint() bool {
272-
return c.hasMethod("PM1.GetStatus")
268+
return c.hasMethod("Switch.GetStatus") || c.hasMethod("PM1.GetStatus")
273269
}
274270

275271
func (c *gen2) hasEM1Endpoint() bool {

0 commit comments

Comments
 (0)