verbose messaging and ha topic

This commit is contained in:
proddy
2018-09-24 21:03:10 +02:00
parent d6e6800617
commit 0bf9e78d4b
2 changed files with 5 additions and 5 deletions

View File

@@ -822,7 +822,7 @@ void ESPHelper::consoleProcessCommand() {
resetESP(); resetESP();
} else if (cmd == '&') { } else if (cmd == '&') {
_verboseMessages = !_verboseMessages; // toggle _verboseMessages = !_verboseMessages; // toggle
telnetClient.printf("Verbose messaging is %s\n", _verboseMessages ? "on" : "off"); telnetClient.printf("Verbose messaging is %s\n\r", _verboseMessages ? "on" : "off");
} else { } else {
// custom Project commands // custom Project commands
if (_consoleCallbackProjectCmds) { if (_consoleCallbackProjectCmds) {
@@ -842,8 +842,7 @@ void ESPHelper::logger(log_level_t level, const char * message) {
telnetClient.flush(); telnetClient.flush();
} else if (level == LOG_HA) { } else if (level == LOG_HA) {
char s[100]; char s[100];
sprintf(s, "%s: %s\n", _hostname, sprintf(s, "%s: %s\n", _hostname, message); // add new line, for the debug telnet printer
message); // add new line, for the debug telnet printer
publish(MQTT_NOTIFICATION, s, false); publish(MQTT_NOTIFICATION, s, false);
} }
@@ -860,7 +859,7 @@ void ESPHelper::logger(log_level_t level, const char * message) {
// send specific command to HA via MQTT // send specific command to HA via MQTT
// format is: home/<hostname>/command/<cmd> // format is: home/<hostname>/command/<cmd>
void ESPHelper::sendHACommand(const char * cmd) { void ESPHelper::sendHACommand(const char * cmd) {
logger(LOG_CONSOLE, "Sending command to HA..."); //logger(LOG_CONSOLE, "Sending command to HA...");
char s[100]; char s[100];
sprintf(s, "%s%s/%s", MQTT_BASE, _hostname, MQTT_TOPIC_COMMAND); sprintf(s, "%s%s/%s", MQTT_BASE, _hostname, MQTT_TOPIC_COMMAND);
@@ -871,7 +870,7 @@ void ESPHelper::sendHACommand(const char * cmd) {
// send specific start command to HA via MQTT, which returns the boottime // send specific start command to HA via MQTT, which returns the boottime
// format is: home/<hostname>/start // format is: home/<hostname>/start
void ESPHelper::sendStart() { void ESPHelper::sendStart() {
logger(LOG_CONSOLE, "Sending Start command to HA..."); //logger(LOG_CONSOLE, "Sending Start command to HA...");
char s[100]; char s[100];
sprintf(s, "%s%s/%s", MQTT_BASE, _hostname, MQTT_TOPIC_START); sprintf(s, "%s%s/%s", MQTT_BASE, _hostname, MQTT_TOPIC_START);

View File

@@ -34,6 +34,7 @@
#define MQTT_NOTIFICATION MQTT_BASE "notification" #define MQTT_NOTIFICATION MQTT_BASE "notification"
#define MQTT_TOPIC_COMMAND "command" #define MQTT_TOPIC_COMMAND "command"
#define MQTT_TOPIC_START "start" #define MQTT_TOPIC_START "start"
#define MQTT_HA MQTT_BASE "ha"
#define MAX_SUBSCRIPTIONS 25 // max # of subscriptions #define MAX_SUBSCRIPTIONS 25 // max # of subscriptions
#define MAX_TIME_INACTIVE 600000 // Max time for inactivity (ms) - 10 mins #define MAX_TIME_INACTIVE 600000 // Max time for inactivity (ms) - 10 mins