MQTT: Small fixes. Most notably, MQTT_TOPIC/status will now contain hostname and IP of pitrix.
This commit is contained in:
parent
90c0df093e
commit
82fbc7be43
13
src/mqtt.cpp
13
src/mqtt.cpp
@ -58,7 +58,12 @@ void mqtt_callback(char* original_topic, byte* pl, unsigned int length) {
|
||||
|
||||
if(topic.compareTo("mode")==0) {
|
||||
LOGln("MQTT * Changing mode...");
|
||||
change_current_effect(payload);
|
||||
bool result = change_current_effect(payload);
|
||||
if (result) {
|
||||
LOGln("MQTT * Effect changed.");
|
||||
} else {
|
||||
LOGln("MQTT * Could not change effect.");
|
||||
}
|
||||
return;
|
||||
} else if (topic.compareTo("reboot")==0) {
|
||||
LOGln("MQTT * Rebooting");
|
||||
@ -85,10 +90,12 @@ void mqtt_callback(char* original_topic, byte* pl, unsigned int length) {
|
||||
}
|
||||
|
||||
boolean mqtt_connect() {
|
||||
LOG("MQTT * Connecting to MQTT server with client id %s", hostname);
|
||||
LOGln("MQTT * Connecting to MQTT server with client id %s", hostname);
|
||||
if (mqtt_client.connect(hostname, MQTT_USER, MQTT_PASS, MQTT_TOPIC "status", 0, true, "OFFLINE", true)) {
|
||||
LOGln("MQTT * Connected.");
|
||||
mqtt_client.publish(MQTT_TOPIC "status", "ONLINE", true);
|
||||
char buffer[40];
|
||||
snprintf(buffer, 40, "ONLINE %s %s", hostname, WiFi.localIP().toString().c_str());
|
||||
mqtt_client.publish(MQTT_TOPIC "status", buffer, true);
|
||||
mqtt_client.subscribe(MQTT_TOPIC "+");
|
||||
mqtt_client.subscribe(MQTT_TOPIC_WEATHER "#");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user