summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2026-03-25 21:37:20 +0100
committerxengineering <me@xengineering.eu>2026-03-25 21:37:20 +0100
commit4bc67b734dc8c90dd4679877e8825da32e67b7eb (patch)
treefc4b97bdb6b91caff22b771bb9d8f5ca64791772 /config.go
parent7afbc98e6d715eef8809beb9793ccf5096104e26 (diff)
parent6001997a66c4c4b12e9d8b0853fef0fc0ff14768 (diff)
downloadsia-server-4bc67b734dc8c90dd4679877e8825da32e67b7eb.tar
sia-server-4bc67b734dc8c90dd4679877e8825da32e67b7eb.tar.zst
sia-server-4bc67b734dc8c90dd4679877e8825da32e67b7eb.zip
Merge branch 'shelly'
This adds basic support for Shelly 2PM Gen3 devices.
Diffstat (limited to 'config.go')
-rw-r--r--config.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/config.go b/config.go
index d39efca..a294b6c 100644
--- a/config.go
+++ b/config.go
@@ -31,7 +31,7 @@ func init() {
mqttTopicPrefixRegexp = regexp.MustCompile(MQTT_TOPIC_PREFIX_REGEX)
}
-//go:embed configs/default.json
+//go:embed configs/valid/default.json
var defaultConfig []byte
type MQTTConfig struct {
@@ -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
}