Skip to content

Commit

Permalink
More config and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
GJSBRT committed Mar 17, 2024
1 parent 0f6cd88 commit 762de9b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 2 additions & 1 deletion control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit 762de9b

Please sign in to comment.