TPLink/Tasmota: support power-less switching using standbypower < 0 (#2505)

This commit is contained in:
Markus Thierolf 2022-02-06 11:50:39 +01:00 • committed by GitHub
parent cafd124a64
commit 518f937055
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 16 deletions

View file

@ -161,12 +161,25 @@ func (c *Shelly) MaxCurrent(current int64) error {
// Status implements the api.Charger interface
func (c *Shelly) Status() (api.ChargeStatus, error) {
power, err := c.CurrentPower()
if power > c.standbypower {
return api.StatusC, err
res := api.StatusB
// static mode
if c.standbypower < 0 {
on, err := c.Enabled()
if on {
res = api.StatusC
}
return res, err
}
return api.StatusB, err
// standby power mode
power, err := c.CurrentPower()
if power > c.standbypower {
res = api.StatusC
}
return res, err
}
var _ api.Meter = (*Shelly)(nil)

View file

@ -100,14 +100,25 @@ func (c *Tasmota) MaxCurrent(current int64) error {
// Status implements the api.Charger interface
func (c *Tasmota) Status() (api.ChargeStatus, error) {
power, err := c.CurrentPower()
res := api.StatusB
switch {
case power > 0:
return api.StatusC, err
default:
return api.StatusB, err
// static mode
if c.standbypower < 0 {
on, err := c.Enabled()
if on {
res = api.StatusC
}
return res, err
}
// standby power mode
power, err := c.CurrentPower()
if power > c.standbypower {
res = api.StatusC
}
return res, err
}
var _ api.Meter = (*Tasmota)(nil)

View file

@ -98,14 +98,25 @@ func (c *TPLink) MaxCurrent(current int64) error {
// Status implements the api.Charger interface
func (c *TPLink) Status() (api.ChargeStatus, error) {
power, err := c.CurrentPower()
res := api.StatusB
switch {
case power > 0:
return api.StatusC, err
default:
return api.StatusB, err
// static mode
if c.standbypower < 0 {
on, err := c.Enabled()
if on {
res = api.StatusC
}
return res, err
}
// standby power mode
power, err := c.CurrentPower()
if power > c.standbypower {
res = api.StatusC
}
return res, err
}
var _ api.Meter = (*TPLink)(nil)