diff --git a/config.yaml.dist b/config.yaml.dist index 76e8cfa..ab60c00 100644 --- a/config.yaml.dist +++ b/config.yaml.dist @@ -47,4 +47,5 @@ control: # I'm not sure how well the batteries like being set to discharge and stop every 5s so I think you do not want to change this below 30s. loop-interval: 30 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 + 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. diff --git a/control/control.go b/control/control.go index 0925b49..5da5b2f 100644 --- a/control/control.go +++ b/control/control.go @@ -17,6 +17,7 @@ type Config struct { Run bool `mapstructure:"run"` MinimumSolarOverProduction int `mapstructure:"minimum-solar-over-production"` OverDischargePercentage int `mapstructure:"over-discharge-percentage"` + MinimumBatteryCapacity int `mapstructure:"minimum-battery-capacity"` } type Control struct { @@ -173,7 +174,7 @@ func (c *Control) Start() { for _, battery := range batteries { if wattsRequired > 0 { - if battery.capacity > 5 { + if battery.capacity > float64(c.config.MinimumBatteryCapacity) { var useWatts uint if wattsRequired > 5000 { useWatts = 5000 diff --git a/metrics/metrics_test.go b/metrics/metrics_test.go index a719148..c95b741 100644 --- a/metrics/metrics_test.go +++ b/metrics/metrics_test.go @@ -36,7 +36,7 @@ func TestSet(t *testing.T) { t.Fatalf("Metric not found") } - if metric.Values[0].Value != 1.0 { + if metric.Values[0].Values[0] != 1.0 { t.Fatalf("Incorrect value") } }