summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md11
-rw-r--r--mqtt.go2
2 files changed, 13 insertions, 0 deletions
diff --git a/README.md b/README.md
index e0555a0..845a068 100644
--- a/README.md
+++ b/README.md
@@ -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/mqtt.go b/mqtt.go
index acd0108..26b6444 100644
--- a/mqtt.go
+++ b/mqtt.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