More comment cleanups
This commit is contained in:
parent
e8efc60c2f
commit
e678daba4d
9 changed files with 34 additions and 32 deletions
|
|
@ -233,6 +233,8 @@ func (c *Easee) MaxCurrentMillis(current float64) error {
|
|||
return err
|
||||
}
|
||||
|
||||
var _ api.Meter = (*Easee)(nil)
|
||||
|
||||
// CurrentPower implements the api.Meter interface.
|
||||
func (c *Easee) CurrentPower() (float64, error) {
|
||||
res, err := c.state()
|
||||
|
|
|
|||
|
|
@ -123,12 +123,12 @@ func (nrg *NRGKickConnect) putJSON(url string, data interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Status implements the api.ChargerStatus interface
|
||||
// Status implements the api.Charger interface
|
||||
func (nrg *NRGKickConnect) Status() (api.ChargeStatus, error) {
|
||||
return api.StatusC, nil
|
||||
}
|
||||
|
||||
// Enabled implements the api.ChargerEnabled interface
|
||||
// Enabled implements the api.Charger 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 api.ChargerEnable interface
|
||||
// Enable implements the api.Charger 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 api.ChargerMaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (nrg *NRGKickConnect) MaxCurrent(current int64) error {
|
||||
settings := NRGSettings{}
|
||||
settings.Values.DeviceMetadata.Password = nrg.password
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ func NewPhoenixEMEth(uri string, id uint8) (*PhoenixEMEth, error) {
|
|||
return wb, nil
|
||||
}
|
||||
|
||||
// Status implements the api.ChargerStatus interface
|
||||
// Status implements the api.Charger 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 api.ChargerEnabled interface
|
||||
// Enabled implements the api.Charger 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 api.ChargerEnable interface
|
||||
// Enable implements the api.Charger 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 api.ChargerMaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (wb *PhoenixEMEth) MaxCurrent(current int64) error {
|
||||
if current < 6 {
|
||||
return fmt.Errorf("invalid current %d", current)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ func NewPhoenixEVEth(uri string, id uint8) (*PhoenixEVEth, error) {
|
|||
return wb, nil
|
||||
}
|
||||
|
||||
// Status implements the api.ChargerStatus interface
|
||||
// Status implements the api.Charger 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 api.ChargerEnabled interface
|
||||
// Enabled implements the api.Charger 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 api.ChargerEnable interface
|
||||
// Enable implements the api.Charger 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 api.ChargerMaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (wb *PhoenixEVEth) MaxCurrent(current int64) error {
|
||||
if current < 6 {
|
||||
return fmt.Errorf("invalid current %d", current)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func NewPhoenixEVSer(uri, device, comset string, baudrate int, id uint8) (*Phoen
|
|||
return wb, nil
|
||||
}
|
||||
|
||||
// Status implements the api.ChargerStatus interface
|
||||
// Status implements the api.Charger 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 api.ChargerEnabled interface
|
||||
// Enabled implements the api.Charger 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 api.ChargerEnable interface
|
||||
// Enable implements the api.Charger 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 api.ChargerMaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger 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 api.ChargerStatus interface
|
||||
// Status implements the api.Charger 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 api.ChargerEnabled interface
|
||||
// Enabled implements the api.Charger 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 api.ChargerEnable interface
|
||||
// Enable implements the api.Charger 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 api.ChargerMaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger 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 api.ChargerEnabled interface
|
||||
// Enabled implements the api.Charger 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 api.ChargerEnable interface
|
||||
// Enable implements the api.Charger 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 api.ChargerMaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (c *Tasmota) MaxCurrent(current int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Status implements the api.ChargerStatus interface
|
||||
// Status implements the api.Charger 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 api.ChargerEnabled interface
|
||||
// Enabled implements the api.Charger 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 api.ChargerEnable interface
|
||||
// Enable implements the api.Charger 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 api.ChargerMaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (c *TPLink) MaxCurrent(current int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Status implements the api.ChargerStatus interface
|
||||
// Status implements the api.Charger 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 api.ChargerStatus interface
|
||||
// Status implements the api.Charger 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 api.ChargerEnabled interface
|
||||
// Enabled implements the api.Charger 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 api.ChargerEnable interface
|
||||
// Enable implements the api.Charger 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 api.ChargerMaxCurrent interface
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (wb *Wallbe) MaxCurrent(current int64) error {
|
||||
if current < 6 {
|
||||
return fmt.Errorf("invalid current %d", current)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue