Skip to content

Commit 403e953

Browse files
authored
Improve charging with Sunny Home Manager (#468)
1 parent ebb99fd commit 403e953

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

core/loadpoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ func (lp *LoadPoint) Update(sitePower float64) {
793793
}
794794

795795
// Sunny Home Manager
796-
if mode == api.ModePV && lp.remoteControlled(RemoteSoftDisable) {
796+
if lp.remoteControlled(RemoteSoftDisable) {
797797
remoteDisabled = RemoteSoftDisable
798798
targetCurrent = 0
799799
required = true

hems/semp/semp.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ func (s *SEMP) deviceRootHandler(w http.ResponseWriter, r *http.Request) {
216216
msg := Device2EMMsg()
217217
msg.DeviceInfo = append(msg.DeviceInfo, s.allDeviceInfo()...)
218218
msg.DeviceStatus = append(msg.DeviceStatus, s.allDeviceStatus()...)
219+
msg.PlanningRequest = append(msg.PlanningRequest, s.allPlanningRequest()...)
219220
s.writeXML(w, msg)
220221
}
221222

@@ -344,7 +345,7 @@ func (s *SEMP) deviceStatus(id int, lp core.LoadPointAPI) DeviceStatus {
344345

345346
isPV := false
346347
if modeP, err := s.cache.GetChecked(id, "mode"); err == nil {
347-
if mode, ok := modeP.Val.(api.ChargeMode); ok && mode == api.ModePV {
348+
if mode, ok := modeP.Val.(api.ChargeMode); ok && (mode == api.ModeMinPV || mode == api.ModePV) {
348349
isPV = true
349350
}
350351
}
@@ -394,7 +395,7 @@ func (s *SEMP) planningRequest(id int, lp core.LoadPointAPI) (res PlanningReques
394395
}
395396

396397
latestEnd := int(chargeEstimate / time.Second)
397-
if mode == api.ModePV || latestEnd <= 0 {
398+
if mode == api.ModeMinPV || mode == api.ModePV || latestEnd <= 0 {
398399
latestEnd = 24 * 3600
399400
}
400401

@@ -404,7 +405,7 @@ func (s *SEMP) planningRequest(id int, lp core.LoadPointAPI) (res PlanningReques
404405
}
405406

406407
// add 1kWh in case we're charging but battery claims full
407-
if maxEnergy == 0 {
408+
if charging && maxEnergy == 0 {
408409
maxEnergy = 1e3 // 1kWh
409410
}
410411

@@ -413,7 +414,7 @@ func (s *SEMP) planningRequest(id int, lp core.LoadPointAPI) (res PlanningReques
413414
minEnergy = 0
414415
}
415416

416-
if charging {
417+
if maxEnergy > 0 {
417418
res = PlanningRequest{
418419
Timeframe: []Timeframe{{
419420
DeviceID: s.deviceID(id),
@@ -462,7 +463,7 @@ func (s *SEMP) deviceControlHandler(w http.ResponseWriter, r *http.Request) {
462463
continue
463464
}
464465

465-
if mode := lp.GetMode(); mode != api.ModePV {
466+
if mode := lp.GetMode(); mode != api.ModeMinPV && mode != api.ModePV {
466467
w.WriteHeader(http.StatusBadRequest)
467468
return
468469
}

0 commit comments

Comments
 (0)