diff options
| author | xengineering <me@xengineering.eu> | 2026-03-27 14:46:04 +0100 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-03-27 14:46:04 +0100 |
| commit | ea47c2fd4eb17cc9ce0dc9fbe6f7d325e8be77b2 (patch) | |
| tree | b19a858d67cab60bf0f4be400d332e972aa6a426 | |
| parent | 0fb9d297871e57372c469c6e8ca2b43813ed1f52 (diff) | |
| parent | 3158a0a132d6af4de78c9be90e45834350cfd414 (diff) | |
| download | sia-server-ea47c2fd4eb17cc9ce0dc9fbe6f7d325e8be77b2.tar sia-server-ea47c2fd4eb17cc9ce0dc9fbe6f7d325e8be77b2.tar.zst sia-server-ea47c2fd4eb17cc9ce0dc9fbe6f7d325e8be77b2.zip | |
Merge branch 'server-version'
This is required to let the client identify the server version.
| -rw-r--r-- | README.md | 11 | ||||
| -rw-r--r-- | VERSION.txt | 1 | ||||
| -rw-r--r-- | main.go | 4 | ||||
| -rw-r--r-- | meson.build | 3 | ||||
| -rw-r--r-- | mqtt.go | 2 | ||||
| -rw-r--r-- | version.go | 13 |
6 files changed, 31 insertions, 3 deletions
@@ -105,6 +105,17 @@ For all terms not explained here see the [MQTT version 3.1.1 documentation][9]. - `good`: Sia server is connected to MQTT broker - `bad`: Sia server is disconnected from MQTT broker +### `/server/version` + +- description: Sia server version string from VERSION.txt +- direction: Sia server to client +- Quality of Service: QoS 1 (at least once) +- retained: yes +- receives will message: no +- topic parameters: none +- payloads: + - `<version>`: version string of the publishing Sia server without newline + ### `/contact/<id>/state` - description: Indicates state of Homematic IP SWDO-2 contacts diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..0d4d124 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +0.1.0-dev @@ -13,8 +13,8 @@ func main() { flags := Flags{} flags.FromArgs() - log.Println("+++ Started Sia server +++") - defer log.Println("--- Stopped Sia server ---") + log.Printf("+++ Started Sia server version %s +++", Version()) + defer log.Printf("--- Stopped Sia server version %s ---", Version()) config := GetStartupConfig(flags.ConfigPath) diff --git a/meson.build b/meson.build index 0738894..f830b42 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project( 'sia-server', - version : '0.1.0-dev', + version : files('VERSION.txt'), ) go = find_program('go', required : true) @@ -18,6 +18,7 @@ changelog = fs.copyfile(meson.current_source_dir() / 'CHANGELOG.md') sia_server_linux_amd64 = custom_target( input : [ meson.current_source_dir() / 'main.go', + meson.current_source_dir() / 'version.go', meson.current_source_dir() / 'cache.go', meson.current_source_dir() / 'mqtt.go', meson.current_source_dir() / 'homematic.go', @@ -46,6 +46,7 @@ func (m MQTTMessage) String() string { func MQTTRun(config MQTTConfig, tx chan MQTTMessage, routes ...Route) { mqttServerHealthTopic = fmt.Sprintf("%s/server/health", config.TopicPrefix) + mqttServerVersionTopic := fmt.Sprintf("%s/server/version", config.TopicPrefix) opts := mqtt.NewClientOptions() opts.AddBroker(config.Broker) @@ -54,6 +55,7 @@ func MQTTRun(config MQTTConfig, tx chan MQTTMessage, routes ...Route) { opts.SetOnConnectHandler(func(c mqtt.Client) { log.Printf("Connected to MQTT broker.") c.Publish(mqttServerHealthTopic, QoS1, true, []byte(`good`)) + c.Publish(mqttServerVersionTopic, QoS1, true, []byte(Version())) for _, route := range routes { topic := config.TopicPrefix + "/" + route.Topic diff --git a/version.go b/version.go new file mode 100644 index 0000000..91d58bc --- /dev/null +++ b/version.go @@ -0,0 +1,13 @@ +package main + +import ( + _ "embed" + "strings" +) + +//go:embed VERSION.txt +var rawVersion string + +func Version() string { + return strings.TrimSuffix(rawVersion, "\n") +} |
