Openevse: fix api (#28479)

This commit is contained in:
Joe Auricchio 2026-03-23 02:24:38 -07:00 • committed by GitHub
parent 0d027945a3
commit 803cc3166c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 8 deletions

View file

@ -199,7 +199,7 @@ func (c *OpenEVSE) ChargedEnergy() (float64, error) {
return 0, err
}
return res.SessionEnergy / 1e3, err
return res.Wattsec / 3600 / 1e3, err
}
var _ api.ChargeTimer = (*OpenEVSE)(nil)
@ -210,7 +210,7 @@ func (c *OpenEVSE) ChargeDuration() (time.Duration, error) {
return 0, err
}
return time.Duration(res.SessionElapsed) * time.Second, err
return time.Duration(res.Elapsed) * time.Second, err
}
var _ api.MeterEnergy = (*OpenEVSE)(nil)
@ -222,7 +222,7 @@ func (c *OpenEVSE) TotalEnergy() (float64, error) {
return 0, err
}
return res.TotalEnergy, err
return res.Watthour / 1e3, err
}
var _ api.Meter = (*OpenEVSE)(nil)
@ -233,7 +233,7 @@ func (c *OpenEVSE) CurrentPower() (float64, error) {
return 0, err
}
return res.Power, err
return res.Amp * res.Voltage / 1e3, err
}
// phases1p3p implements the api.PhaseSwitcher interface

View file

@ -12,14 +12,12 @@ type Status struct {
ManualOverride int `json:"manual_override,omitempty"` // 1 = active, 0 = default
Mode string `json:"mode,omitempty"` // The current mode of the EVSE
Pilot int `json:"pilot,omitempty"` // the pilot value, in amps
Power float64 `json:"power,omitempty"` // apparent power in watts
SessionEnergy float64 `json:"session_energy"` // The total amount of energy accumulated for current session (in wh)
SessionElapsed int `json:"session_elapsed"` // duration of this charging session in seconds
State int `json:"state,omitempty"` // evse state 1=A 2=B 3=C 4=D 5-11=F 254=sleeping 255=disabled
Status string `json:"status,omitempty"` // active, disabled, none, unknown
TotalEnergy float64 `json:"total_energy"` // The total amount of energy accumulated (in kwh)
Vehicle int `json:"vehicle,omitempty"` // 0=not connected, 1=connected
Voltage float64 `json:"voltage,omitempty"` // supplied via MQTT/Tesla/HTTP or assume a default
Watthour float64 `json:"watthour,omitempty"` // The total amount of energy accumulated (in watt-hours)
Wattsec float64 `json:"wattsec,omitempty"` // The total amount of energy accumulated for current session (in watt-seconds)
}
type Override struct {