Skip to content

Commit

Permalink
chore: fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Oct 20, 2024
1 parent 98f2f90 commit 27e45a2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ func (site *Site) updatePvMeters() {
var mu sync.Mutex

site.pvPower = 0
site.excessDCPower = 0

mm := make([]meterMeasurement, len(site.pvMeters))

Expand Down Expand Up @@ -484,8 +485,8 @@ func (site *Site) updatePvMeters() {
site.excessDCPower += dc
mu.Unlock()

excessDC = dc
excessStr = fmt.Sprintf(" (includes %.0fW excess DC)", dc)
excessDC = -dc
excessStr = fmt.Sprintf(" (includes %.0fW excess DC)", -dc)
}
}

Expand All @@ -508,7 +509,12 @@ func (site *Site) updatePvMeters() {
}
wg.Wait()

site.log.DEBUG.Printf("pv power: %.0fW", site.pvPower)
var excessStr string
if site.excessDCPower < 0 {
excessStr = fmt.Sprintf(" (includes %.0fW excess DC)", -site.excessDCPower)
}

site.log.DEBUG.Printf("pv power: %.0fW"+excessStr, site.pvPower)
site.publish(keys.PvPower, site.pvPower)
site.publish(keys.PvEnergy, totalEnergy)
site.publish(keys.Pv, mm)
Expand Down Expand Up @@ -581,7 +587,6 @@ func (site *Site) updateBatteryMeters() error {
var mu sync.Mutex

site.batteryPower = 0
site.excessDCPower = 0
site.batterySoc = 0

mm := make([]batteryMeasurement, len(site.batteryMeters))
Expand Down Expand Up @@ -673,12 +678,7 @@ func (site *Site) updateBatteryMeters() error {
site.log.DEBUG.Printf("battery soc: %.0f%%", math.Round(site.batterySoc))
site.publish(keys.BatterySoc, site.batterySoc)

var excessStr string
if site.excessDCPower > 0 {
excessStr = fmt.Sprintf(" (includes %.0fW excess DC)", site.excessDCPower)
}

site.log.DEBUG.Printf("battery power: %.0fW"+excessStr, site.batteryPower)
site.log.DEBUG.Printf("battery power: %.0fW", site.batteryPower)
site.publish(keys.BatteryPower, site.batteryPower)
site.publish(keys.BatteryEnergy, totalEnergy)
site.publish(keys.Battery, mm)
Expand Down

0 comments on commit 27e45a2

Please sign in to comment.