Skip to content

Commit

Permalink
Added control example config and added over discharge config
Browse files Browse the repository at this point in the history
  • Loading branch information
GJSBRT committed Mar 17, 2024
1 parent 9a5a09f commit 0f6cd88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions config.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ victoria-metrics:
# Basic HTTP authentication
username:
password:

control:
run: true # Run control loop?
# How often to run checks in seconds.
# 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
3 changes: 2 additions & 1 deletion control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
type Config struct {
Run bool `mapstructure:"run"`
MinimumSolarOverProduction int `mapstructure:"minimum-solar-over-production"`
OverDischargePercentage int `mapstructure:"over-discharge-percentage"`
}

type Control struct {
Expand Down Expand Up @@ -162,7 +163,7 @@ func (c *Control) Start() {
}

// 5. if solar production < home energy consumption && battery capacity > 5%, discharge battery
wattsRequired := math.Ceil(avgHomeLoad - avgSolarIn)
wattsRequired := math.Ceil(avgHomeLoad - avgSolarIn) * ((100 + float64(c.config.OverDischargePercentage)) / 100)
if avgSolarIn < avgHomeLoad {
if wattsRequired > 0 {
metrics.SetMetricValue("control", "action", map[string]string{"action": "discharge_battery"}, 1)
Expand Down

0 comments on commit 0f6cd88

Please sign in to comment.