diff --git a/Readme.md b/Readme.md index 943b796..08e6c33 100644 --- a/Readme.md +++ b/Readme.md @@ -35,7 +35,7 @@ Determine the IP address of your clock and execute the following script: * GPIO0 factory reset (long during operation) ## MQTT Interface -* **basetopic**/command +* **basetopic**/cmd/single ** ON Set brightness to 100% ** OFF Set brightness to 0% ** 0-100 Set brightness to given value diff --git a/mqtt.lua b/mqtt.lua index c672b15..2504766 100644 --- a/mqtt.lua +++ b/mqtt.lua @@ -41,7 +41,7 @@ function registerMqtt() print(topic .. ":" ) if data ~= nil then print(data) - if (topic == (mqttPrefix .. "/command")) then + if (topic == (mqttPrefix .. "/cmd/single")) then handleSingleCommand(client, topic, data) else -- Handle here the /cmd/# sublevel @@ -63,11 +63,10 @@ function registerMqtt() print("MQTT is connected") mqttConnected = true -- subscribe topic with qos = 0 - client:subscribe(mqttPrefix .. "/command", 0) - tmr.alarm(3, 500, 0, function() + client:subscribe(mqttPrefix .. "/cmd/#", 0) + tmr.alarm(3, 1000, 0, function() -- publish a message with data = hello, QoS = 0, retain = 0 client:publish(mqttPrefix .. "/ip", tostring(wifi.sta.getip()), 0, 0) - client:subscribe(mqttPrefix .. "/cmd/#", 0) end) end, function(client, reason)