diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 3032f5d8..88fb2ad6 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -73,8 +73,7 @@ #define MQTT_BUTTON_TOPIC "/button" #define MQTT_IP_TOPIC "/ip" #define MQTT_VERSION_TOPIC "/version" -#define MQTT_FSVERSION_TOPIC "/fsversion" -#define MQTT_HEARTBEAT_TOPIC "/heartbeat" +#define MQTT_HEARTBEAT_TOPIC "/status" #define MQTT_CONNECT_EVENT 0 #define MQTT_DISCONNECT_EVENT 1 diff --git a/code/espurna/data/index.html.gz b/code/espurna/data/index.html.gz index 0f4ed804..116a554a 100644 Binary files a/code/espurna/data/index.html.gz and b/code/espurna/data/index.html.gz differ diff --git a/code/espurna/data/password.html.gz b/code/espurna/data/password.html.gz index 2bb3023e..8f9b50ba 100644 Binary files a/code/espurna/data/password.html.gz and b/code/espurna/data/password.html.gz differ diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index b0302d55..f5658b68 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -78,7 +78,6 @@ void _mqttOnConnect(bool sessionPresent) { // Build MQTT topics buildTopics(); - mqtt.setWill((mqttTopic + MQTT_HEARTBEAT_TOPIC).c_str(), MQTT_QOS, MQTT_RETAIN, (char *) "0"); // Say hello and report our IP and VERSION mqttSend(MQTT_IP_TOPIC, getIP().c_str()); @@ -141,7 +140,7 @@ void mqttConnect() { DEBUG_MSG("[MQTT] Connecting to broker at %s", host); mqtt.setServer(host, port); mqtt.setKeepAlive(MQTT_KEEPALIVE).setCleanSession(false); - mqtt.setWill(MQTT_HEARTBEAT_TOPIC, MQTT_QOS, MQTT_RETAIN, "0"); + mqtt.setWill((mqttTopic + MQTT_HEARTBEAT_TOPIC).c_str(), MQTT_QOS, MQTT_RETAIN, "0"); if ((strlen(user) > 0) && (strlen(pass) > 0)) { DEBUG_MSG(" as user '%s'.", user); mqtt.setCredentials(user, pass); @@ -157,6 +156,7 @@ void mqttSetup() { mqtt.onConnect(_mqttOnConnect); mqtt.onDisconnect(_mqttOnDisconnect); mqtt.onMessage(_mqttOnMessage); + buildTopics(); } void mqttLoop() { diff --git a/code/html/index.html b/code/html/index.html index 7c0736d4..b28c70e5 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -331,8 +331,8 @@ - <root>/relay/# Send a 0 or a 1 as a payload to this topic to switch it on or off. You can also send a 2 to toggle its current state. Replace # with the relay ID (starting from 0). If the board has only one relay it will be 0.
- <root>/led/# Send a 0 or a 1 as a payload to this topic to set the onboard LED to the given state, send a 3 to turn it back to WIFI indicator. Replace # with the LED ID (starting from 0). If the board has only one LED it will be 0.
- <root>/ip The device will report to this topic its IP.
- - <root>/heartbeat The device will report to this topic every few minutes.
- <root>/version The device will report to this topic its firmware version on boot.
+ - <root>/status The device will report a 1 to this topic every few minutes. Upon MQTT disconnecting this will be set to 0.