diff options
| -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 |
