Skip to content

Commit

Permalink
Add configurable battery charge percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
GJSBRT committed Apr 6, 2024
1 parent b7cb108 commit 377bfb1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ control:
minimum-solar-over-production: 10 # Minimum percentage solar over production. This is the percentage of unused power.
over-discharge-percentage: 3 # What percentage to over discharge. Handy for spikes in energy usage.
minimum-battery-capacity: 5 # Minimum capacity to leave in the batteries.
battery-charge-percentage: 90 # Percentage to charge batteries. If your over production is 1000w then 900w will be used to charge the batteries.

3 changes: 2 additions & 1 deletion control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Config struct {
MinimumSolarOverProduction int `mapstructure:"minimum-solar-over-production"`
OverDischargePercentage int `mapstructure:"over-discharge-percentage"`
MinimumBatteryCapacity int `mapstructure:"minimum-battery-capacity"`
BatteryChargePercentage int `mapstructure:"battery-charge-percentage"`
}

type Control struct {
Expand Down Expand Up @@ -138,7 +139,7 @@ func (c *Control) Start() {
metrics.SetMetricValue("control", "action", map[string]string{"action": "charge_batteries"}, 1)

// charge batteries with 20% less than over production
batteryChargeWatts := uint(math.Floor(float64(overProductionWatts) * 0.90)) / uint(len(batteries))
batteryChargeWatts := uint(math.Floor(float64(overProductionWatts) * (float64(c.config.BatteryChargePercentage) / 100)))

for _, battery := range batteries {
if battery.capacity < 100 {
Expand Down

0 comments on commit 377bfb1

Please sign in to comment.