summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2026-03-26 17:25:27 +0100
committerxengineering <me@xengineering.eu>2026-03-26 17:31:34 +0100
commitaecc47c3f558dc3f0548d4c8e69f20ed893f5196 (patch)
treef76d5940e8d7e3bc86daae616bca0dfef60abf6a
parent5bfb53eb9bb16eebc9bc2751d8c9c5baea6a6b37 (diff)
downloadsia-server-aecc47c3f558dc3f0548d4c8e69f20ed893f5196.tar
sia-server-aecc47c3f558dc3f0548d4c8e69f20ed893f5196.tar.zst
sia-server-aecc47c3f558dc3f0548d4c8e69f20ed893f5196.zip
Add TP-Link config parsing
This is required to assign IDs and IP addresses.
-rw-r--r--config.go15
-rw-r--r--configs/valid/tplink.json17
2 files changed, 32 insertions, 0 deletions
diff --git a/config.go b/config.go
index a294b6c..93f4459 100644
--- a/config.go
+++ b/config.go
@@ -52,10 +52,18 @@ type ShellyConfig struct {
type ShellyConfigs []ShellyConfig
+type TPLinkConfig struct {
+ ID string `json:"id"`
+ IP string `json:"ip"`
+}
+
+type TPLinkConfigs []TPLinkConfig
+
type StartupConfig struct {
MQTT MQTTConfig `json:"mqtt"`
Homematic HomematicConfig `json:"homematic"`
Shelly ShellyConfigs `json:"shelly"`
+ TPLink TPLinkConfigs `json:"tplink"`
}
func (sc StartupConfig) String() string {
@@ -132,6 +140,13 @@ func (sc StartupConfig) Validate() error {
}
}
+ for _, tplink := range sc.TPLink {
+ ip := net.ParseIP(tplink.IP)
+ if ip == nil {
+ return fmt.Errorf("Failed to parse IP address '%s'.", tplink.IP)
+ }
+ }
+
return nil
}
diff --git a/configs/valid/tplink.json b/configs/valid/tplink.json
new file mode 100644
index 0000000..f672fa4
--- /dev/null
+++ b/configs/valid/tplink.json
@@ -0,0 +1,17 @@
+{
+ "mqtt": {
+ "broker": "tcp://127.0.0.1:1883",
+ "client-id": "siaserver",
+ "topic-prefix": "sia"
+ },
+ "homematic": {
+ "ccu": "http://127.0.0.1:8080",
+ "polling-period": "50ms"
+ },
+ "tplink": [
+ {
+ "id": "tplink1",
+ "ip": "192.168.1.40"
+ }
+ ]
+}