summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2026-03-23 17:59:33 +0100
committerxengineering <me@xengineering.eu>2026-03-23 21:36:30 +0100
commit5b25200b8afea648b5598c97a9566f8bc5c0aff7 (patch)
treeaf6ec85cf7da94a8c647c1d87bc78705d6f0ad0e /config.go
parent91844eb24c16d7ba768f913597702f8075fe8af2 (diff)
downloadsia-server-5b25200b8afea648b5598c97a9566f8bc5c0aff7.tar
sia-server-5b25200b8afea648b5598c97a9566f8bc5c0aff7.tar.zst
sia-server-5b25200b8afea648b5598c97a9566f8bc5c0aff7.zip
WIP: Add shelly configuration parsing
TODO: Add strict checks for config like uniqueness of IDs. This allows to specify Shelly cover devices to be added to the configuration file with all information required by the Sia server.
Diffstat (limited to 'config.go')
-rw-r--r--config.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/config.go b/config.go
index b3cd9dc..a294b6c 100644
--- a/config.go
+++ b/config.go
@@ -45,9 +45,17 @@ type HomematicConfig struct {
PollingPeriod string `json:"polling-period"`
}
+type ShellyConfig struct {
+ ID string `json:"id"`
+ IP string `json:"ip"`
+}
+
+type ShellyConfigs []ShellyConfig
+
type StartupConfig struct {
MQTT MQTTConfig `json:"mqtt"`
Homematic HomematicConfig `json:"homematic"`
+ Shelly ShellyConfigs `json:"shelly"`
}
func (sc StartupConfig) String() string {
@@ -117,6 +125,13 @@ func (sc StartupConfig) Validate() error {
return fmt.Errorf("homematic/polling-period configuration '%s' could not be parsed to duration: %v", sc.Homematic.PollingPeriod, err)
}
+ for _, shelly := range sc.Shelly {
+ ip := net.ParseIP(shelly.IP)
+ if ip == nil {
+ return fmt.Errorf("Failed to parse IP address '%s'.", shelly.IP)
+ }
+ }
+
return nil
}