Shelly: re-enable PM Mini Gen3 (#20855)

This commit is contained in:
Markus Thierolf 2025-04-25 13:05:42 +02:00 • committed by GitHub
parent 8fb8efb16b
commit 4d6bf165a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -109,12 +109,6 @@ func newGen2(helper *request.Helper, uri, model string, channel int, user, passw
c.Client.Transport = digest.NewTransport(user, password, c.Client.Transport)
}
c.switchstatus = util.ResettableCached(apiCall[Gen2SwitchStatus](c, "Switch.GetStatus"), cache)
c.em1status = util.Cached(apiCall[Gen2EM1Status](c, "EM1.GetStatus"), cache)
c.em1data = util.Cached(apiCall[Gen2EM1Data](c, "EM1Data.GetStatus"), cache)
c.emstatus = util.Cached(apiCall[Gen2EMStatus](c, "EM.GetStatus"), cache)
c.emdata = util.Cached(apiCall[Gen2EMData](c, "EMData.GetStatus"), cache)
var res Gen2Methods
if err := c.execCmd("Shelly.ListMethods", false, &res); err != nil {
return nil, err
@ -122,6 +116,16 @@ func newGen2(helper *request.Helper, uri, model string, channel int, user, passw
c.methods = res.Methods
if c.hasPM1Endpoint() {
c.switchstatus = util.ResettableCached(apiCall[Gen2SwitchStatus](c, "PM1.GetStatus"), cache)
} else {
c.switchstatus = util.ResettableCached(apiCall[Gen2SwitchStatus](c, "Switch.GetStatus"), cache)
}
c.em1status = util.Cached(apiCall[Gen2EM1Status](c, "EM1.GetStatus"), cache)
c.em1data = util.Cached(apiCall[Gen2EM1Data](c, "EM1Data.GetStatus"), cache)
c.emstatus = util.Cached(apiCall[Gen2EMStatus](c, "EM.GetStatus"), cache)
c.emdata = util.Cached(apiCall[Gen2EMData](c, "EMData.GetStatus"), cache)
return c, nil
}
@ -264,6 +268,10 @@ func (c *gen2) hasSwitchEndpoint() bool {
return c.hasMethod("Switch.GetStatus")
}
func (c *gen2) hasPM1Endpoint() bool {
return c.hasMethod("PM1.GetStatus")
}
func (c *gen2) hasEM1Endpoint() bool {
return c.hasMethod("EM1.GetStatus")
}