Cleanup api comments
This commit is contained in:
parent
c1269e2f06
commit
2fd2bc23f2
17 changed files with 92 additions and 85 deletions
|
|
@ -78,7 +78,7 @@ func NewConfigurable(
|
|||
return c, nil
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.Charger interface
|
||||
func (m *Charger) Status() (api.ChargeStatus, error) {
|
||||
s, err := m.statusG()
|
||||
if err != nil {
|
||||
|
|
@ -88,17 +88,17 @@ func (m *Charger) Status() (api.ChargeStatus, error) {
|
|||
return api.ChargeStatus(s), nil
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.Charger interface
|
||||
func (m *Charger) Enabled() (bool, error) {
|
||||
return m.enabledG()
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.Charger interface
|
||||
func (m *Charger) Enable(enable bool) error {
|
||||
return m.enableS(enable)
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (m *Charger) MaxCurrent(current int64) error {
|
||||
return m.maxCurrentS(current)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/andig/evcc/api"
|
||||
"github.com/andig/evcc/core"
|
||||
"github.com/andig/evcc/internal/charger/easee"
|
||||
"github.com/andig/evcc/util"
|
||||
"github.com/andig/evcc/util/request"
|
||||
|
|
@ -144,7 +145,7 @@ func (c *Easee) state() (easee.ChargerStatus, error) {
|
|||
return c.status, err
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.Charger interface
|
||||
func (c *Easee) Status() (api.ChargeStatus, error) {
|
||||
res, err := c.state()
|
||||
if err != nil {
|
||||
|
|
@ -165,13 +166,13 @@ func (c *Easee) Status() (api.ChargeStatus, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.Charger interface
|
||||
func (c *Easee) Enabled() (bool, error) {
|
||||
res, err := c.state()
|
||||
return res.DynamicCircuitCurrentP1 > 0, err
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.Charger interface
|
||||
func (c *Easee) Enable(enable bool) error {
|
||||
res, err := c.state()
|
||||
if err != nil {
|
||||
|
|
@ -208,12 +209,14 @@ func (c *Easee) Enable(enable bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (c *Easee) MaxCurrent(current int64) error {
|
||||
return c.MaxCurrentMillis(float64(current))
|
||||
}
|
||||
|
||||
// MaxCurrentMillis implements the Charger.MaxCurrentMillis interface
|
||||
var _ api.ChargerEx = (*Easee)(nil)
|
||||
|
||||
// MaxCurrentMillis implements the api.ChargerEx interface
|
||||
func (c *Easee) MaxCurrentMillis(current float64) error {
|
||||
cur := int(current)
|
||||
data := easee.CircuitSettings{
|
||||
|
|
@ -231,19 +234,23 @@ func (c *Easee) MaxCurrentMillis(current float64) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// CurrentPower implements the Meter interface.
|
||||
// CurrentPower implements the api.Meter interface.
|
||||
func (c *Easee) CurrentPower() (float64, error) {
|
||||
res, err := c.state()
|
||||
return 1e3 * res.TotalPower, err
|
||||
}
|
||||
|
||||
// ChargedEnergy implements the ChargeRater interface
|
||||
var _ api.ChargeRater = (*Easee)(nil)
|
||||
|
||||
// ChargedEnergy implements the api.ChargeRater interface
|
||||
func (c *Easee) ChargedEnergy() (float64, error) {
|
||||
res, err := c.state()
|
||||
return res.SessionEnergy, err
|
||||
}
|
||||
|
||||
// Currents implements the MeterCurrent interface
|
||||
var _ api.MeterCurrent = (*Easee)(nil)
|
||||
|
||||
// Currents implements the api.MeterCurrent interface
|
||||
func (c *Easee) Currents() (float64, float64, float64, error) {
|
||||
res, err := c.state()
|
||||
return res.CircuitTotalPhaseConductorCurrentL1,
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ func (evse *EVSEWifi) HasMeter() (bool, error) {
|
|||
return params.UseMeter, err
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.Charger interface
|
||||
func (evse *EVSEWifi) Status() (api.ChargeStatus, error) {
|
||||
params, err := evse.getParameters()
|
||||
if err != nil {
|
||||
|
|
@ -175,7 +175,7 @@ func (evse *EVSEWifi) Status() (api.ChargeStatus, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.Charger interface
|
||||
func (evse *EVSEWifi) Enabled() (bool, error) {
|
||||
params, err := evse.getParameters()
|
||||
return params.EvseState, err
|
||||
|
|
@ -189,7 +189,7 @@ func (evse *EVSEWifi) checkError(b []byte, err error) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.Charger interface
|
||||
func (evse *EVSEWifi) Enable(enable bool) error {
|
||||
url := fmt.Sprintf("%s?active=%v", evse.apiURL(evseSetStatus), enable)
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ func (evse *EVSEWifi) Enable(enable bool) error {
|
|||
return evse.checkError(evse.GetBody(url))
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (evse *EVSEWifi) MaxCurrent(current int64) error {
|
||||
evse.current = current
|
||||
url := fmt.Sprintf("%s?current=%d", evse.apiURL(evseSetCurrent), current)
|
||||
|
|
@ -212,25 +212,25 @@ func (evse *EVSEWifi) MaxCurrent(current int64) error {
|
|||
|
||||
var _ api.ChargeTimer = (*EVSEWifi)(nil)
|
||||
|
||||
// ChargingTime yields current charge run duration
|
||||
// ChargingTime implements the api.ChargeTimer interface
|
||||
func (evse *EVSEWifi) ChargingTime() (time.Duration, error) {
|
||||
params, err := evse.getParameters()
|
||||
return time.Duration(params.Duration) * time.Millisecond, err
|
||||
}
|
||||
|
||||
// CurrentPower implements the Meter interface
|
||||
// CurrentPower implements the api.Meter interface
|
||||
func (evse *EVSEWifi) currentPower() (float64, error) {
|
||||
params, err := evse.getParameters()
|
||||
return 1000 * params.ActualPower, err
|
||||
}
|
||||
|
||||
// TotalEnergy implements the MeterEnergy interface
|
||||
// TotalEnergy implements the api.MeterEnergy interface
|
||||
func (evse *EVSEWifi) totalEnergy() (float64, error) {
|
||||
params, err := evse.getParameters()
|
||||
return params.MeterReading, err
|
||||
}
|
||||
|
||||
// Currents implements the MeterCurrents interface
|
||||
// Currents implements the api.MeterCurrents interface
|
||||
func (evse *EVSEWifi) currents() (float64, float64, float64, error) {
|
||||
params, err := evse.getParameters()
|
||||
return float64(params.CurrentP1), float64(params.CurrentP2), float64(params.CurrentP3), err
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ func (c *FritzDECT) execFritzDectCmd(function string) (string, error) {
|
|||
return strings.TrimSpace(string(response)), err
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.Charger interface
|
||||
func (c *FritzDECT) Status() (api.ChargeStatus, error) {
|
||||
|
||||
// present 0/1 - DECT Switch connected to fritzbox (no/yes)
|
||||
|
|
@ -130,7 +130,7 @@ func (c *FritzDECT) Status() (api.ChargeStatus, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.Charger interface
|
||||
func (c *FritzDECT) Enabled() (bool, error) {
|
||||
// state 0/1 - DECT Switch state off/on (empty if unkown or error)
|
||||
resp, err := c.execFritzDectCmd("getswitchstate")
|
||||
|
|
@ -143,7 +143,7 @@ func (c *FritzDECT) Enabled() (bool, error) {
|
|||
return state == 1, err
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.Charger interface
|
||||
func (c *FritzDECT) Enable(enable bool) error {
|
||||
cmd := "setswitchoff"
|
||||
if enable {
|
||||
|
|
@ -170,7 +170,7 @@ func (c *FritzDECT) Enable(enable bool) error {
|
|||
}
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (c *FritzDECT) MaxCurrent(current int64) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ func isValid(status goeStatusResponse) bool {
|
|||
return status.Fwv != ""
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.Charger interface
|
||||
func (c *GoE) Status() (api.ChargeStatus, error) {
|
||||
status, err := c.apiStatus()
|
||||
if err != nil {
|
||||
|
|
@ -167,7 +167,7 @@ func (c *GoE) Status() (api.ChargeStatus, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.Charger interface
|
||||
func (c *GoE) Enabled() (bool, error) {
|
||||
status, err := c.apiStatus()
|
||||
if err != nil {
|
||||
|
|
@ -184,7 +184,7 @@ func (c *GoE) Enabled() (bool, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.Charger interface
|
||||
func (c *GoE) Enable(enable bool) error {
|
||||
var b int
|
||||
if enable {
|
||||
|
|
@ -199,7 +199,7 @@ func (c *GoE) Enable(enable bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (c *GoE) MaxCurrent(current int64) error {
|
||||
status, err := c.apiUpdate(fmt.Sprintf("amx=%d", current))
|
||||
if err == nil && isValid(status) && int64(status.Amp) != current {
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ func (c *Keba) roundtrip(msg string, report int, res interface{}) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.Charger interface
|
||||
func (c *Keba) Status() (api.ChargeStatus, error) {
|
||||
var kr keba.Report2
|
||||
err := c.roundtrip("report", 2, &kr)
|
||||
|
|
@ -182,7 +182,7 @@ func (c *Keba) Status() (api.ChargeStatus, error) {
|
|||
return api.StatusA, fmt.Errorf("unexpected status: %+v", kr)
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.Charger interface
|
||||
func (c *Keba) Enabled() (bool, error) {
|
||||
var kr keba.Report2
|
||||
err := c.roundtrip("report", 2, &kr)
|
||||
|
|
@ -213,7 +213,7 @@ func (c *Keba) enableRFID() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.Charger interface
|
||||
func (c *Keba) Enable(enable bool) error {
|
||||
if enable && c.rfid.Tag != "" {
|
||||
if err := c.enableRFID(); err != nil {
|
||||
|
|
@ -235,7 +235,7 @@ func (c *Keba) Enable(enable bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (c *Keba) MaxCurrent(current int64) error {
|
||||
d := 1000 * current
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ func (c *Keba) MaxCurrentMillis(current float64) error {
|
|||
|
||||
var _ api.Meter = (*Keba)(nil)
|
||||
|
||||
// CurrentPower implements the Meter interface
|
||||
// CurrentPower implements the api.Meter interface
|
||||
func (c *Keba) CurrentPower() (float64, error) {
|
||||
var kr keba.Report3
|
||||
err := c.roundtrip("report", 3, &kr)
|
||||
|
|
@ -277,7 +277,7 @@ func (c *Keba) CurrentPower() (float64, error) {
|
|||
|
||||
var _ api.MeterEnergy = (*Keba)(nil)
|
||||
|
||||
// TotalEnergy implements the MeterEnergy interface
|
||||
// TotalEnergy implements the api.MeterEnergy interface
|
||||
func (c *Keba) TotalEnergy() (float64, error) {
|
||||
var kr keba.Report3
|
||||
err := c.roundtrip("report", 3, &kr)
|
||||
|
|
@ -299,7 +299,7 @@ func (c *Keba) ChargedEnergy() (float64, error) {
|
|||
|
||||
var _ api.MeterCurrent = (*Keba)(nil)
|
||||
|
||||
// Currents implements the MeterCurrents interface
|
||||
// Currents implements the api.MeterCurrent interface
|
||||
func (c *Keba) Currents() (float64, float64, float64, error) {
|
||||
var kr keba.Report3
|
||||
err := c.roundtrip("report", 3, &kr)
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ func (mcc *MobileConnect) getEscapedJSON(uri string, result interface{}) error {
|
|||
return json.Unmarshal([]byte(s), &result)
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.Charger interface
|
||||
func (mcc *MobileConnect) Status() (api.ChargeStatus, error) {
|
||||
b, err := mcc.getValue(mcc.apiURL(mccAPIChargeState))
|
||||
if err != nil {
|
||||
|
|
@ -245,7 +245,7 @@ func (mcc *MobileConnect) Status() (api.ChargeStatus, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.Charger interface
|
||||
func (mcc *MobileConnect) Enabled() (bool, error) {
|
||||
// Check if the car is connected and Paused, Active, or Finished
|
||||
b, err := mcc.getValue(mcc.apiURL(mccAPIChargeState))
|
||||
|
|
@ -266,13 +266,13 @@ func (mcc *MobileConnect) Enabled() (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.Charger interface
|
||||
func (mcc *MobileConnect) Enable(enable bool) error {
|
||||
// As we don't know of the API to disable charging this for now always returns an error
|
||||
return nil
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (mcc *MobileConnect) MaxCurrent(current int64) error {
|
||||
// The device doesn't return an error if we set a value greater than the
|
||||
// current allowed max or smaller than the allowed min
|
||||
|
|
@ -316,7 +316,7 @@ func (mcc *MobileConnect) MaxCurrent(current int64) error {
|
|||
|
||||
var _ api.Meter = (*MobileConnect)(nil)
|
||||
|
||||
// CurrentPower implements the Meter interface.
|
||||
// CurrentPower implements the api.Meter interface
|
||||
func (mcc *MobileConnect) CurrentPower() (float64, error) {
|
||||
var energy MCCEnergy
|
||||
err := mcc.getEscapedJSON(mcc.apiURL(mccAPIEnergy), &energy)
|
||||
|
|
@ -326,7 +326,7 @@ func (mcc *MobileConnect) CurrentPower() (float64, error) {
|
|||
|
||||
var _ api.ChargeRater = (*MobileConnect)(nil)
|
||||
|
||||
// ChargedEnergy implements the ChargeRater interface.
|
||||
// ChargedEnergy implements the api.ChargeRater interface
|
||||
func (mcc *MobileConnect) ChargedEnergy() (float64, error) {
|
||||
var currentSession MCCCurrentSession
|
||||
if err := mcc.getEscapedJSON(mcc.apiURL(mccAPICurrentSession), ¤tSession); err != nil {
|
||||
|
|
@ -338,7 +338,7 @@ func (mcc *MobileConnect) ChargedEnergy() (float64, error) {
|
|||
|
||||
var _ api.ChargeTimer = (*MobileConnect)(nil)
|
||||
|
||||
// ChargingTime yields current charge run duration
|
||||
// ChargingTime implements the api.ChargeTimer interface
|
||||
func (mcc *MobileConnect) ChargingTime() (time.Duration, error) {
|
||||
var currentSession MCCCurrentSession
|
||||
if err := mcc.getEscapedJSON(mcc.apiURL(mccAPICurrentSession), ¤tSession); err != nil {
|
||||
|
|
@ -350,7 +350,7 @@ func (mcc *MobileConnect) ChargingTime() (time.Duration, error) {
|
|||
|
||||
var _ api.MeterCurrent = (*MobileConnect)(nil)
|
||||
|
||||
// Currents implements the MeterCurrent interface
|
||||
// Currents implements the api.MeterCurrent interface
|
||||
func (mcc *MobileConnect) Currents() (float64, float64, float64, error) {
|
||||
var energy MCCEnergy
|
||||
err := mcc.getEscapedJSON(mcc.apiURL(mccAPIEnergy), &energy)
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ func (nrg *NRGKickBLE) mergeSettings(info nrgble.Info) nrgble.Settings {
|
|||
}
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.Charger interface
|
||||
func (nrg *NRGKickBLE) Status() (api.ChargeStatus, error) {
|
||||
res := nrgble.Power{}
|
||||
if err := nrg.read(nrgble.PowerService, &res); err != nil {
|
||||
|
|
@ -239,7 +239,7 @@ func (nrg *NRGKickBLE) Status() (api.ChargeStatus, error) {
|
|||
return api.StatusA, fmt.Errorf("unexpected cp signal: %d", res.CPSignal)
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.Charger interface
|
||||
func (nrg *NRGKickBLE) Enabled() (bool, error) {
|
||||
res := nrgble.Info{}
|
||||
if err := nrg.read(nrgble.InfoService, &res); err != nil {
|
||||
|
|
@ -254,7 +254,7 @@ func (nrg *NRGKickBLE) Enabled() (bool, error) {
|
|||
return !res.PauseCharging || res.ChargingActive, nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.Charger interface
|
||||
func (nrg *NRGKickBLE) Enable(enable bool) error {
|
||||
res := nrgble.Info{}
|
||||
if err := nrg.read(nrgble.InfoService, &res); err != nil {
|
||||
|
|
@ -281,7 +281,7 @@ func (nrg *NRGKickBLE) Enable(enable bool) error {
|
|||
return nrg.write(nrgble.SettingsService, &settings)
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (nrg *NRGKickBLE) MaxCurrent(current int64) error {
|
||||
res := nrgble.Info{}
|
||||
if err := nrg.read(nrgble.InfoService, &res); err != nil {
|
||||
|
|
|
|||
|
|
@ -123,12 +123,12 @@ func (nrg *NRGKickConnect) putJSON(url string, data interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.ChargerStatus interface
|
||||
func (nrg *NRGKickConnect) Status() (api.ChargeStatus, error) {
|
||||
return api.StatusC, nil
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.ChargerEnabled interface
|
||||
func (nrg *NRGKickConnect) Enabled() (bool, error) {
|
||||
var res NRGSettings
|
||||
err := nrg.GetJSON(nrg.apiURL(nrgSettings), &res)
|
||||
|
|
@ -143,7 +143,7 @@ func (nrg *NRGKickConnect) Enabled() (bool, error) {
|
|||
return *res.Values.ChargingStatus.Charging, nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.ChargerEnable interface
|
||||
func (nrg *NRGKickConnect) Enable(enable bool) error {
|
||||
settings := NRGSettings{}
|
||||
settings.Values.DeviceMetadata.Password = nrg.password
|
||||
|
|
@ -152,7 +152,7 @@ func (nrg *NRGKickConnect) Enable(enable bool) error {
|
|||
return nrg.putJSON(nrg.apiURL(nrgSettings), settings)
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.ChargerMaxCurrent interface
|
||||
func (nrg *NRGKickConnect) MaxCurrent(current int64) error {
|
||||
settings := NRGSettings{}
|
||||
settings.Values.DeviceMetadata.Password = nrg.password
|
||||
|
|
@ -163,7 +163,7 @@ func (nrg *NRGKickConnect) MaxCurrent(current int64) error {
|
|||
|
||||
var _ api.Meter = (*NRGKickConnect)(nil)
|
||||
|
||||
// CurrentPower implements the Meter interface
|
||||
// CurrentPower implements the api.Meter interface
|
||||
func (nrg *NRGKickConnect) CurrentPower() (float64, error) {
|
||||
var res NRGMeasurements
|
||||
err := nrg.GetJSON(nrg.apiURL(nrgMeasurements), &res)
|
||||
|
|
@ -176,7 +176,7 @@ func (nrg *NRGKickConnect) CurrentPower() (float64, error) {
|
|||
|
||||
var _ api.MeterEnergy = (*NRGKickConnect)(nil)
|
||||
|
||||
// TotalEnergy implements the MeterEnergy interface
|
||||
// TotalEnergy implements the api.MeterEnergy interface
|
||||
func (nrg *NRGKickConnect) TotalEnergy() (float64, error) {
|
||||
var res NRGMeasurements
|
||||
err := nrg.GetJSON(nrg.apiURL(nrgMeasurements), &res)
|
||||
|
|
@ -189,7 +189,7 @@ func (nrg *NRGKickConnect) TotalEnergy() (float64, error) {
|
|||
|
||||
var _ api.MeterCurrent = (*NRGKickConnect)(nil)
|
||||
|
||||
// Currents implements the MeterCurrent interface
|
||||
// Currents implements the api.MeterCurrent interface
|
||||
func (nrg *NRGKickConnect) Currents() (float64, float64, float64, error) {
|
||||
var res NRGMeasurements
|
||||
err := nrg.GetJSON(nrg.apiURL(nrgMeasurements), &res)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ func NewPhoenixEMEth(uri string, id uint8) (*PhoenixEMEth, error) {
|
|||
return wb, nil
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.ChargerStatus interface
|
||||
func (wb *PhoenixEMEth) Status() (api.ChargeStatus, error) {
|
||||
b, err := wb.conn.ReadInputRegisters(phxEMEthRegStatus, 1)
|
||||
if err != nil {
|
||||
|
|
@ -98,7 +98,7 @@ func (wb *PhoenixEMEth) Status() (api.ChargeStatus, error) {
|
|||
return api.ChargeStatus(string(b[1])), nil
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.ChargerEnabled interface
|
||||
func (wb *PhoenixEMEth) Enabled() (bool, error) {
|
||||
b, err := wb.conn.ReadCoils(phxEMEthRegEnable, 1)
|
||||
if err != nil {
|
||||
|
|
@ -108,7 +108,7 @@ func (wb *PhoenixEMEth) Enabled() (bool, error) {
|
|||
return b[0] == 1, nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.ChargerEnable interface
|
||||
func (wb *PhoenixEMEth) Enable(enable bool) error {
|
||||
var u uint16
|
||||
if enable {
|
||||
|
|
@ -120,7 +120,7 @@ func (wb *PhoenixEMEth) Enable(enable bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.ChargerMaxCurrent interface
|
||||
func (wb *PhoenixEMEth) MaxCurrent(current int64) error {
|
||||
if current < 6 {
|
||||
return fmt.Errorf("invalid current %d", current)
|
||||
|
|
@ -133,7 +133,7 @@ func (wb *PhoenixEMEth) MaxCurrent(current int64) error {
|
|||
|
||||
var _ api.ChargeTimer = (*PhoenixEMEth)(nil)
|
||||
|
||||
// ChargingTime yields current charge run duration
|
||||
// ChargingTime implements the api.ChargeTimer interface
|
||||
func (wb *PhoenixEMEth) ChargingTime() (time.Duration, error) {
|
||||
b, err := wb.conn.ReadInputRegisters(phxEMEthRegChargeTime, 2)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ func NewPhoenixEVEth(uri string, id uint8) (*PhoenixEVEth, error) {
|
|||
return wb, nil
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.ChargerStatus interface
|
||||
func (wb *PhoenixEVEth) Status() (api.ChargeStatus, error) {
|
||||
b, err := wb.conn.ReadInputRegisters(phxEVEthRegStatus, 1)
|
||||
if err != nil {
|
||||
|
|
@ -99,7 +99,7 @@ func (wb *PhoenixEVEth) Status() (api.ChargeStatus, error) {
|
|||
return api.ChargeStatus(string(b[1])), nil
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.ChargerEnabled interface
|
||||
func (wb *PhoenixEVEth) Enabled() (bool, error) {
|
||||
b, err := wb.conn.ReadCoils(phxEVEthRegEnable, 1)
|
||||
if err != nil {
|
||||
|
|
@ -109,7 +109,7 @@ func (wb *PhoenixEVEth) Enabled() (bool, error) {
|
|||
return b[0] == 1, nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.ChargerEnable interface
|
||||
func (wb *PhoenixEVEth) Enable(enable bool) error {
|
||||
var u uint16
|
||||
if enable {
|
||||
|
|
@ -121,7 +121,7 @@ func (wb *PhoenixEVEth) Enable(enable bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.ChargerMaxCurrent interface
|
||||
func (wb *PhoenixEVEth) MaxCurrent(current int64) error {
|
||||
if current < 6 {
|
||||
return fmt.Errorf("invalid current %d", current)
|
||||
|
|
@ -134,7 +134,7 @@ func (wb *PhoenixEVEth) MaxCurrent(current int64) error {
|
|||
|
||||
var _ api.ChargeTimer = (*PhoenixEVEth)(nil)
|
||||
|
||||
// ChargingTime yields current charge run duration
|
||||
// ChargingTime implements the api.ChargeTimer interface
|
||||
func (wb *PhoenixEVEth) ChargingTime() (time.Duration, error) {
|
||||
b, err := wb.conn.ReadInputRegisters(phxEVEthRegChargeTime, 2)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func NewPhoenixEVSer(uri, device, comset string, baudrate int, id uint8) (*Phoen
|
|||
return wb, nil
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.ChargerStatus interface
|
||||
func (wb *PhoenixEVSer) Status() (api.ChargeStatus, error) {
|
||||
b, err := wb.conn.ReadInputRegisters(phxEVSerRegStatus, 1)
|
||||
if err != nil {
|
||||
|
|
@ -68,7 +68,7 @@ func (wb *PhoenixEVSer) Status() (api.ChargeStatus, error) {
|
|||
return api.ChargeStatus(string(b[0])), nil
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.ChargerEnabled interface
|
||||
func (wb *PhoenixEVSer) Enabled() (bool, error) {
|
||||
b, err := wb.conn.ReadCoils(phxEVSerRegEnable, 1)
|
||||
if err != nil {
|
||||
|
|
@ -78,7 +78,7 @@ func (wb *PhoenixEVSer) Enabled() (bool, error) {
|
|||
return b[0] == 1, nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.ChargerEnable interface
|
||||
func (wb *PhoenixEVSer) Enable(enable bool) error {
|
||||
var u uint16
|
||||
if enable {
|
||||
|
|
@ -90,7 +90,7 @@ func (wb *PhoenixEVSer) Enable(enable bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.ChargerMaxCurrent interface
|
||||
func (wb *PhoenixEVSer) MaxCurrent(current int64) error {
|
||||
if current < 6 {
|
||||
return fmt.Errorf("invalid current %d", current)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func NewSimpleEVSE(uri, device, comset string, baudrate int, rtu bool, slaveID u
|
|||
return evse, nil
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.ChargerStatus interface
|
||||
func (evse *SimpleEVSE) Status() (api.ChargeStatus, error) {
|
||||
b, err := evse.conn.ReadHoldingRegisters(evseRegVehicleStatus, 1)
|
||||
if err != nil {
|
||||
|
|
@ -85,7 +85,7 @@ func (evse *SimpleEVSE) Status() (api.ChargeStatus, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.ChargerEnabled interface
|
||||
func (evse *SimpleEVSE) Enabled() (bool, error) {
|
||||
b, err := evse.conn.ReadHoldingRegisters(evseRegAmpsConfig, 1)
|
||||
if err != nil {
|
||||
|
|
@ -100,7 +100,7 @@ func (evse *SimpleEVSE) Enabled() (bool, error) {
|
|||
return enabled, nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.ChargerEnable interface
|
||||
func (evse *SimpleEVSE) Enable(enable bool) error {
|
||||
b := []byte{0, 0}
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ func (evse *SimpleEVSE) Enable(enable bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.ChargerMaxCurrent interface
|
||||
func (evse *SimpleEVSE) MaxCurrent(current int64) error {
|
||||
b := []byte{0, byte(current)}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ func NewTasmota(uri, user, password string, standbypower float64) (*Tasmota, err
|
|||
return c, nil
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.ChargerEnabled interface
|
||||
func (c *Tasmota) Enabled() (bool, error) {
|
||||
var tStatus tasmota.StatusResponse
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ func (c *Tasmota) Enabled() (bool, error) {
|
|||
return int(1) == tStatus.Status.Power, err
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.ChargerEnable interface
|
||||
func (c *Tasmota) Enable(enable bool) error {
|
||||
var tPower tasmota.PowerResponse
|
||||
|
||||
|
|
@ -100,12 +100,12 @@ func (c *Tasmota) Enable(enable bool) error {
|
|||
}
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.ChargerMaxCurrent interface
|
||||
func (c *Tasmota) MaxCurrent(current int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.ChargerStatus interface
|
||||
func (c *Tasmota) Status() (api.ChargeStatus, error) {
|
||||
power, err := c.CurrentPower()
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ func NewTPLink(uri string, standbypower float64) (*TPLink, error) {
|
|||
return c, nil
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.ChargerEnabled interface
|
||||
func (c *TPLink) Enabled() (bool, error) {
|
||||
var resp tplink.SystemResponse
|
||||
if err := c.execCmd(`{"system":{"get_sysinfo":null}}`, &resp); err != nil {
|
||||
|
|
@ -72,7 +72,7 @@ func (c *TPLink) Enabled() (bool, error) {
|
|||
return resp.System.GetSysinfo.RelayState == 1, nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.ChargerEnable interface
|
||||
func (c *TPLink) Enable(enable bool) error {
|
||||
cmd := `{"system":{"set_relay_state":{"state":0}}}`
|
||||
if enable {
|
||||
|
|
@ -91,12 +91,12 @@ func (c *TPLink) Enable(enable bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.ChargerMaxCurrent interface
|
||||
func (c *TPLink) MaxCurrent(current int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.ChargerStatus interface
|
||||
func (c *TPLink) Status() (api.ChargeStatus, error) {
|
||||
power, err := c.CurrentPower()
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ func NewWallbe(uri string) (*Wallbe, error) {
|
|||
return wb, nil
|
||||
}
|
||||
|
||||
// Status implements the Charger.Status interface
|
||||
// Status implements the api.ChargerStatus interface
|
||||
func (wb *Wallbe) Status() (api.ChargeStatus, error) {
|
||||
b, err := wb.conn.ReadInputRegisters(wbRegStatus, 1)
|
||||
if err != nil {
|
||||
|
|
@ -128,7 +128,7 @@ func (wb *Wallbe) Status() (api.ChargeStatus, error) {
|
|||
return api.ChargeStatus(string(b[1])), nil
|
||||
}
|
||||
|
||||
// Enabled implements the Charger.Enabled interface
|
||||
// Enabled implements the api.ChargerEnabled interface
|
||||
func (wb *Wallbe) Enabled() (bool, error) {
|
||||
b, err := wb.conn.ReadCoils(wbRegEnable, 1)
|
||||
if err != nil {
|
||||
|
|
@ -138,7 +138,7 @@ func (wb *Wallbe) Enabled() (bool, error) {
|
|||
return b[0] == 1, nil
|
||||
}
|
||||
|
||||
// Enable implements the Charger.Enable interface
|
||||
// Enable implements the api.ChargerEnable interface
|
||||
func (wb *Wallbe) Enable(enable bool) error {
|
||||
var u uint16
|
||||
if enable {
|
||||
|
|
@ -150,7 +150,7 @@ func (wb *Wallbe) Enable(enable bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// MaxCurrent implements the Charger.MaxCurrent interface
|
||||
// MaxCurrent implements the api.ChargerMaxCurrent interface
|
||||
func (wb *Wallbe) MaxCurrent(current int64) error {
|
||||
if current < 6 {
|
||||
return fmt.Errorf("invalid current %d", current)
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ func (sm *SMA) CurrentPower() (float64, error) {
|
|||
return values.power, err
|
||||
}
|
||||
|
||||
// Currents implements the MeterCurrent interface
|
||||
// Currents implements the api.MeterCurrent interface
|
||||
func (sm *SMA) Currents() (float64, float64, float64, error) {
|
||||
values, err := sm.hasValue()
|
||||
return values.currentL1, sm.values.currentL2, sm.values.currentL3, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue