Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit ad43b1c

Browse files
committed
Fix types
1 parent 89ef984 commit ad43b1c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

control/control.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (c *Control) Start() {
164164
}
165165

166166
// 5. if solar production < home energy consumption && battery capacity > 5%, discharge battery
167-
wattsRequired := math.Ceil(avgHomeLoad - avgSolarIn) * ((100 + float64(c.config.OverDischargePercentage)) / 100)
167+
wattsRequired := uint(math.Ceil(avgHomeLoad - avgSolarIn) * ((100 + float64(c.config.OverDischargePercentage)) / 100))
168168
if avgSolarIn < avgHomeLoad {
169169
if wattsRequired > 0 {
170170
metrics.SetMetricValue("control", "action", map[string]string{"action": "discharge_battery"}, 1)
@@ -181,10 +181,10 @@ func (c *Control) Start() {
181181
var wattsFromGrid uint
182182
if wattsRequired > maxBatteryDischargeWatts {
183183
wattsFromGrid = uint(wattsRequired) - maxBatteryDischargeWatts
184-
wattsRequired = float64(maxBatteryDischargeWatts)
184+
wattsRequired = maxBatteryDischargeWatts
185185
}
186186

187-
wattsRequiredPerBattery := wattsRequired / float64(len(batteries))
187+
wattsRequiredPerBattery := wattsRequired / uint(len(batteries))
188188

189189
for _, battery := range batteries {
190190
if battery.capacity < float64(c.config.MinimumBatteryCapacity) {

0 commit comments

Comments
 (0)