summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2025-12-20 14:11:13 +0100
committerxengineering <me@xengineering.eu>2025-12-20 14:11:13 +0100
commit224d52d1033d8ccce5087c9bee5a63457830a13a (patch)
treecfd0b61e66258a0121ef20d4572561aee84b8db3 /config.go
parentd6fa255b1df26a12329a614601a027e074aabeb2 (diff)
downloadsia-server-224d52d1033d8ccce5087c9bee5a63457830a13a.tar
sia-server-224d52d1033d8ccce5087c9bee5a63457830a13a.tar.zst
sia-server-224d52d1033d8ccce5087c9bee5a63457830a13a.zip
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.
Diffstat (limited to 'config.go')
-rw-r--r--config.go23
1 files changed, 13 insertions, 10 deletions
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 StartupConfig struct {
- MQTT struct {
- Broker string `json:"broker"`
- ClientID string `json:"client-id"`
- TopicPrefix string `json:"topic-prefix"`
- } `json:"mqtt"`
+type MQTTConfig struct {
+ Broker string `json:"broker"`
+ ClientID string `json:"client-id"`
+ TopicPrefix string `json:"topic-prefix"`
+}
- Homematic struct {
- CCU string `json:"ccu"`
- PollingPeriodMilliseconds int `json:"polling-period-milliseconds"`
- } `json:"homematic"`
+type HomematicConfig struct {
+ CCU string `json:"ccu"`
+ PollingPeriod string `json:"polling-period"`
+}
+
+type StartupConfig struct {
+ MQTT MQTTConfig `json:"mqtt"`
+ Homematic HomematicConfig `json:"homematic"`
}
func (sc *StartupConfig) FromJSON(data []byte) error {