Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CoarseCurrent feature for vehicles that can't follow mA charging #4662

Merged
merged 5 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ func (f *Feature) UnmarshalText(text []byte) error {
const (
_ Feature = iota
Offline
CoarseCurrent
)
16 changes: 10 additions & 6 deletions api/feature_enumer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ func (lp *LoadPoint) setLimit(chargeCurrent float64, force bool) error {
// set current
if chargeCurrent != lp.chargeCurrent && chargeCurrent >= lp.GetMinCurrent() {
var err error
if charger, ok := lp.charger.(api.ChargerEx); ok {
if charger, ok := lp.charger.(api.ChargerEx); ok && !lp.vehicleHasFeature(api.CoarseCurrent) {
err = charger.MaxCurrentMillis(chargeCurrent)
} else {
chargeCurrent = math.Trunc(chargeCurrent)
Expand Down Expand Up @@ -686,12 +686,7 @@ func (lp *LoadPoint) setStatus(status api.ChargeStatus) {

// targetEnergyReached checks if target is configured and reached
func (lp *LoadPoint) targetEnergyReached() bool {
v, ok := lp.vehicle.(api.FeatureDescriber)
if ok {
ok = v.Has(api.Offline)
}

return (v == nil || ok) &&
return (lp.vehicle == nil || lp.vehicleHasFeature(api.Offline)) &&
lp.targetEnergy > 0 &&
lp.chargedEnergy/1e3 >= float64(lp.targetEnergy)
}
Expand Down Expand Up @@ -929,13 +924,18 @@ func (lp *LoadPoint) unpublishVehicle() {
lp.vehiclePublishFeature(api.Offline)
}

// vehiclePublishFeature availability of vehicle features
func (lp *LoadPoint) vehiclePublishFeature(f api.Feature) {
// vehicleHasFeature checks availability of vehicle feature
func (lp *LoadPoint) vehicleHasFeature(f api.Feature) bool {
v, ok := lp.vehicle.(api.FeatureDescriber)
if ok {
ok = v.Has(f)
}
lp.publish("vehicleFeature"+f.String(), ok)
return ok
}

// vehiclePublishFeature availability of vehicle features
func (lp *LoadPoint) vehiclePublishFeature(f api.Feature) {
lp.publish("vehicleFeature"+f.String(), lp.vehicleHasFeature(f))
}

// vehicleUnidentified returns true if there are associated vehicles and detection is running.
Expand Down
9 changes: 4 additions & 5 deletions core/loadpoint_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ func (lp *LoadPoint) GetTargetEnergy() int {
// setTargetEnergy sets loadpoint charge target energy (no mutex)
func (lp *LoadPoint) setTargetEnergy(energy int) {
lp.targetEnergy = energy
// test guard
if lp.socTimer != nil {
// TODO soctimer
// lp.socTimer.Energy = energy
}
// TODO soctimer
// if lp.socTimer != nil {
// lp.socTimer.Energy = energy
// }
lp.publish("targetEnergy", energy)
}

Expand Down