Files
energy-collector/config.go
Thomas Klaehn 62ffd06444 Add go-e wallbox charger integration
- charger.go: polls go-e /api/status?filter=nrg,eto every 10 s
- db.go: WriteCharger() inserts into charger hypertable
- config.go: ChargerConf with host field
- main.go: polls charger in parallel with inverter and meters
- schema.sql: charger table + charger_10m/1h/daily aggregates + policies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 11:30:59 +02:00

58 lines
1.6 KiB
Go

package main
import (
"encoding/json"
"os"
)
type Config struct {
SampleRate int `json:"sample_rate"` // seconds
AlphaEss AlphaConf `json:"alphaess"`
MQTT MQTTConf `json:"mqtt"`
Charger ChargerConf `json:"charger"`
DB DBConf `json:"db"`
}
type ChargerConf struct {
Host string `json:"host"` // hostname or IP of go-e charger
}
type AlphaConf struct {
Host string `json:"host"`
Port int `json:"port"`
SlaveID uint8 `json:"slave_id"`
}
type MQTTConf struct {
Broker string `json:"broker"`
BrokerIP string `json:"broker_ip"` // optional scoped IPv6 e.g. fe80::1%eth0
BrokerTLSName string `json:"broker_tls_name"` // TLS ServerName when broker_ip is set
Port int `json:"port"`
ClientID string `json:"client_id"`
TopicPrefix string `json:"topic_prefix"`
CACert string `json:"ca_cert"`
ClientCert string `json:"client_cert"`
ClientKey string `json:"client_key"`
Devices []DeviceConf `json:"devices"`
}
// DeviceConf describes one SDM630 meter reachable via the MQTT/Modbus bridge.
type DeviceConf struct {
SlaveAddress int `json:"slave_address"`
Name string `json:"name"` // used as the 'device' column value in power_meter
Segment string `json:"segment"` // MQTT topic segment
}
type DBConf struct {
DSN string `json:"dsn"` // PostgreSQL connection string
}
func loadConfig(path string) (Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return Config{}, err
}
var cfg Config
return cfg, json.Unmarshal(data, &cfg)
}