Skip to content

Commit

Permalink
TPLink/Tasmota: support power-less switching using standbypower < 0 (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
thierolm authored Feb 6, 2022
1 parent cafd124 commit 518f937
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 14 deletions.
17 changes: 15 additions & 2 deletions charger/shelly.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,25 @@ func (c *Shelly) MaxCurrent(current int64) error {

// Status implements the api.Charger interface
func (c *Shelly) Status() (api.ChargeStatus, error) {
res := api.StatusB

// 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 {
return api.StatusC, err
res = api.StatusC
}

return api.StatusB, err
return res, err
}

var _ api.Meter = (*Shelly)(nil)
Expand Down
23 changes: 17 additions & 6 deletions charger/tasmota.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 17 additions & 6 deletions charger/tplink.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

// static mode
if c.standbypower < 0 {
on, err := c.Enabled()
if on {
res = api.StatusC
}

return res, err
}

switch {
case power > 0:
return api.StatusC, err
default:
return api.StatusB, err
// standby power mode
power, err := c.CurrentPower()
if power > c.standbypower {
res = api.StatusC
}

return res, err
}

var _ api.Meter = (*TPLink)(nil)
Expand Down

0 comments on commit 518f937

Please sign in to comment.