From 224d52d1033d8ccce5087c9bee5a63457830a13a Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 20 Dec 2025 14:11:13 +0100 Subject: Use default config The default config JSON is embedded as bytes into the executable. Instead of constants the default values are now parsed from these embedded bytes. --- config.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'config.go') diff --git a/config.go b/config.go index 38f0af9..edd6f4b 100644 --- a/config.go +++ b/config.go @@ -9,17 +9,20 @@ import ( //go:embed configs/default.json var defaultConfig []byte +type MQTTConfig struct { + Broker string `json:"broker"` + ClientID string `json:"client-id"` + TopicPrefix string `json:"topic-prefix"` +} + +type HomematicConfig struct { + CCU string `json:"ccu"` + PollingPeriod string `json:"polling-period"` +} + type StartupConfig struct { - MQTT struct { - Broker string `json:"broker"` - ClientID string `json:"client-id"` - TopicPrefix string `json:"topic-prefix"` - } `json:"mqtt"` - - Homematic struct { - CCU string `json:"ccu"` - PollingPeriodMilliseconds int `json:"polling-period-milliseconds"` - } `json:"homematic"` + MQTT MQTTConfig `json:"mqtt"` + Homematic HomematicConfig `json:"homematic"` } func (sc *StartupConfig) FromJSON(data []byte) error { -- cgit v1.2.3-70-g09d2