OpenWB-Pro: support reading initial soc (#9247)

This commit is contained in:
andig 2023-08-04 17:12:52 +02:00 • committed by GitHub
parent de3f93c03d
commit 146c88112d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -151,7 +151,7 @@ func (wb *OpenWBPro) TotalEnergy() (float64, error) {
var _ api.PhaseCurrents = (*OpenWBPro)(nil)
// Currents implements the api.PhaseCurrentss interface
// Currents implements the api.PhaseCurrents interface
func (wb *OpenWBPro) Currents() (float64, float64, float64, error) {
res, err := wb.statusCache.Get()
if err != nil {
@ -165,6 +165,22 @@ func (wb *OpenWBPro) Currents() (float64, float64, float64, error) {
return res.Currents[0], res.Currents[1], res.Currents[2], err
}
var _ api.Battery = (*OpenWBPro)(nil)
// Soc implements the api.Battery interface
func (wb *OpenWBPro) Soc() (float64, error) {
res, err := wb.statusCache.Get()
if err != nil {
return 0, err
}
if time.Since(time.Unix(res.SocTimestamp, 0)) > 5*time.Minute {
return 0, api.ErrNotAvailable
}
return float64(res.Soc), nil
}
var _ api.PhaseSwitcher = (*OpenWBPro)(nil)
// Phases1p3p implements the api.PhaseSwitcher interface

View file

@ -18,5 +18,7 @@ type Status struct {
OfferedCurrent float64 `json:"offered_current"`
EvseSignaling string `json:"evse_signaling"`
VehicleID string `json:"vehicle_id"`
Soc int `json:"soc_value"`
SocTimestamp int64 `json:"soc_timestamp"`
Serial string
}