diff options
| author | xengineering <me@xengineering.eu> | 2026-03-27 14:39:33 +0100 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-03-27 14:43:56 +0100 |
| commit | 3158a0a132d6af4de78c9be90e45834350cfd414 (patch) | |
| tree | b19a858d67cab60bf0f4be400d332e972aa6a426 | |
| parent | 5b64946098839d3df679bdc7ef1c4cc4e692323a (diff) | |
| download | sia-server-3158a0a132d6af4de78c9be90e45834350cfd414.tar sia-server-3158a0a132d6af4de78c9be90e45834350cfd414.tar.zst sia-server-3158a0a132d6af4de78c9be90e45834350cfd414.zip | |
Add server version publishing
This makes it possible that the client adapts it's behaviour easily to
the server version making support of breaking API changes during early
development and debugging easier.
| -rw-r--r-- | README.md | 11 | ||||
| -rw-r--r-- | mqtt.go | 2 |
2 files changed, 13 insertions, 0 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 @@ -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 |
