From 04e6d681f04731c67b9b65fb6a55a21184fd4baa Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 23 Mar 2026 17:25:50 +0100 Subject: Move default.json to configs/valid Since the default configuration is a valid configuration it should belong to this new directory. This allows to continue with extending automated tests to test all configurations in this directory. --- configs/valid/default.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 configs/valid/default.json (limited to 'configs/valid') diff --git a/configs/valid/default.json b/configs/valid/default.json new file mode 100644 index 0000000..b291185 --- /dev/null +++ b/configs/valid/default.json @@ -0,0 +1,11 @@ +{ + "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" + } +} -- cgit v1.3 From 91844eb24c16d7ba768f913597702f8075fe8af2 Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 23 Mar 2026 17:41:22 +0100 Subject: Add test mqtt-topic-prefix-max-characters.json This makes sure the maximum `mqtt/topic-prefix` string length is accepted. --- configs/valid/mqtt-topic-prefix-max-characters.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 configs/valid/mqtt-topic-prefix-max-characters.json (limited to 'configs/valid') diff --git a/configs/valid/mqtt-topic-prefix-max-characters.json b/configs/valid/mqtt-topic-prefix-max-characters.json new file mode 100644 index 0000000..99f3cf1 --- /dev/null +++ b/configs/valid/mqtt-topic-prefix-max-characters.json @@ -0,0 +1,11 @@ +{ + "mqtt": { + "broker": "tcp://127.0.0.1:1883", + "client-id": "siaserver", + "topic-prefix": "aaaaaaaaaaaaaaaaaaaa" + }, + "homematic": { + "ccu": "http://127.0.0.1:8080", + "polling-period": "50ms" + } +} -- cgit v1.3 From 776e6fdd8415edd0daa5743c35cbee029a89c6a7 Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 23 Mar 2026 17:59:33 +0100 Subject: Add shelly configuration parsing This allows to specify Shelly cover devices to be added to the configuration file with all information required by the Sia server. --- config.go | 15 +++++++++++++++ configs/valid/shelly.json | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 configs/valid/shelly.json (limited to 'configs/valid') 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 } diff --git a/configs/valid/shelly.json b/configs/valid/shelly.json new file mode 100644 index 0000000..578f6dc --- /dev/null +++ b/configs/valid/shelly.json @@ -0,0 +1,21 @@ +{ + "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" + }, + "shelly": [ + { + "id": "shelly1", + "ip": "192.168.1.20" + }, + { + "id": "shelly2", + "ip": "2001:db8::68" + } + ] +} -- cgit v1.3