Merge pull request #136 from debsahu/master
fixes and added legacy option
This commit is contained in:
commit
265a1c9437
3 changed files with 358 additions and 319 deletions
|
@ -26,14 +26,14 @@
|
||||||
|
|
||||||
//SPIFFS Save
|
//SPIFFS Save
|
||||||
#if !defined(ENABLE_HOMEASSISTANT) and defined(ENABLE_STATE_SAVE_SPIFFS)
|
#if !defined(ENABLE_HOMEASSISTANT) and defined(ENABLE_STATE_SAVE_SPIFFS)
|
||||||
#include <ArduinoJson.h> //
|
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MQTT
|
// MQTT
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
|
@ -220,7 +220,9 @@ void saveConfigCallback () {
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Include: Color modes
|
// Include: Color modes
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
#include "colormodes.h"
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
#include "colormodes.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// MAIN
|
// MAIN
|
||||||
|
@ -428,7 +430,7 @@ void setup() {
|
||||||
amqttClient.onDisconnect(onMqttDisconnect);
|
amqttClient.onDisconnect(onMqttDisconnect);
|
||||||
amqttClient.onMessage(onMqttMessage);
|
amqttClient.onMessage(onMqttMessage);
|
||||||
amqttClient.setServer(mqtt_host, String(mqtt_port).toInt());
|
amqttClient.setServer(mqtt_host, String(mqtt_port).toInt());
|
||||||
amqttClient.setCredentials(mqtt_user, mqtt_pass);
|
amqttClient.setCredentials(mqtt_user, mqtt_pass);
|
||||||
amqttClient.setClientId(mqtt_clientid);
|
amqttClient.setClientId(mqtt_clientid);
|
||||||
|
|
||||||
connectToMqtt();
|
connectToMqtt();
|
||||||
|
@ -530,18 +532,8 @@ void setup() {
|
||||||
// Setup: SPIFFS Webserver handler
|
// Setup: SPIFFS Webserver handler
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
server.on("/set_brightness", []() {
|
server.on("/set_brightness", []() {
|
||||||
if (server.arg("c").toInt() > 0) {
|
getArgs();
|
||||||
brightness = (int) server.arg("c").toInt() * 2.55;
|
mode = BRIGHTNESS;
|
||||||
} else {
|
|
||||||
brightness = server.arg("p").toInt();
|
|
||||||
}
|
|
||||||
if (brightness > 255) {
|
|
||||||
brightness = 255;
|
|
||||||
}
|
|
||||||
if (brightness < 0) {
|
|
||||||
brightness = 0;
|
|
||||||
}
|
|
||||||
strip.setBrightness(brightness);
|
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String(String("OK %") + String(brightness)).c_str());
|
mqtt_client.publish(mqtt_outtopic, String(String("OK %") + String(brightness)).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -597,7 +589,8 @@ void setup() {
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/get_color", []() {
|
server.on("/get_color", []() {
|
||||||
String rgbcolor = String(main_color.red, HEX) + String(main_color.green, HEX) + String(main_color.blue, HEX);
|
char rgbcolor[7];
|
||||||
|
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X", main_color.red, main_color.green, main_color.blue);
|
||||||
server.send(200, "text/plain", rgbcolor );
|
server.send(200, "text/plain", rgbcolor );
|
||||||
DBG_OUTPUT_PORT.print("/get_color: ");
|
DBG_OUTPUT_PORT.print("/get_color: ");
|
||||||
DBG_OUTPUT_PORT.println(rgbcolor);
|
DBG_OUTPUT_PORT.println(rgbcolor);
|
||||||
|
@ -608,7 +601,9 @@ void setup() {
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/off", []() {
|
server.on("/off", []() {
|
||||||
exit_func = true;
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
exit_func = true;
|
||||||
|
#endif
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
|
@ -627,8 +622,12 @@ void setup() {
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/all", []() {
|
server.on("/all", []() {
|
||||||
exit_func = true;
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
mode = ALL;
|
exit_func = true;
|
||||||
|
#endif
|
||||||
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
|
mode = SET_MODE;
|
||||||
|
//mode = ALL;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
|
@ -645,138 +644,140 @@ void setup() {
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/wipe", []() {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
exit_func = true;
|
server.on("/wipe", []() {
|
||||||
mode = WIPE;
|
exit_func = true;
|
||||||
getArgs();
|
mode = WIPE;
|
||||||
getStatusJSON();
|
getArgs();
|
||||||
#ifdef ENABLE_MQTT
|
getStatusJSON();
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =wipe").c_str());
|
#ifdef ENABLE_MQTT
|
||||||
#endif
|
mqtt_client.publish(mqtt_outtopic, String("OK =wipe").c_str());
|
||||||
#ifdef ENABLE_AMQTT
|
#endif
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =wipe").c_str());
|
#ifdef ENABLE_AMQTT
|
||||||
#endif
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =wipe").c_str());
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#endif
|
||||||
stateOn = true;
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
#endif
|
stateOn = true;
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#endif
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
#endif
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
});
|
#endif
|
||||||
|
});
|
||||||
server.on("/rainbow", []() {
|
|
||||||
exit_func = true;
|
|
||||||
mode = RAINBOW;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
#ifdef ENABLE_MQTT
|
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =rainbow").c_str());
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_AMQTT
|
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbow").c_str());
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
|
||||||
#endif
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/rainbowCycle", []() {
|
|
||||||
exit_func = true;
|
|
||||||
mode = RAINBOWCYCLE;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
#ifdef ENABLE_MQTT
|
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =rainbowCycle").c_str());
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_AMQTT
|
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbowCycle").c_str());
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
|
||||||
#endif
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/theaterchase", []() {
|
|
||||||
exit_func = true;
|
|
||||||
mode = THEATERCHASE;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
#ifdef ENABLE_MQTT
|
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchase").c_str());
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_AMQTT
|
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchase").c_str());
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
|
||||||
#endif
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/twinkleRandom", []() {
|
|
||||||
exit_func = true;
|
|
||||||
mode = TWINKLERANDOM;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
#ifdef ENABLE_MQTT
|
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =twinkleRandom").c_str());
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_AMQTT
|
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =twinkleRandom").c_str());
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
|
||||||
#endif
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/theaterchaseRainbow", []() {
|
server.on("/rainbow", []() {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
mode = THEATERCHASERAINBOW;
|
mode = RAINBOW;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchaseRainbow").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =rainbow").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AMQTT
|
#ifdef ENABLE_AMQTT
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchaseRainbow").c_str());
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbow").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/tv", []() {
|
server.on("/rainbowCycle", []() {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
mode = TV;
|
mode = RAINBOWCYCLE;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =tv").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =rainbowCycle").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AMQTT
|
#ifdef ENABLE_AMQTT
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =tv").c_str());
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbowCycle").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.on("/theaterchase", []() {
|
||||||
|
exit_func = true;
|
||||||
|
mode = THEATERCHASE;
|
||||||
|
getArgs();
|
||||||
|
getStatusJSON();
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchase").c_str());
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_AMQTT
|
||||||
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchase").c_str());
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
|
#endif
|
||||||
|
});
|
||||||
|
|
||||||
|
server.on("/twinkleRandom", []() {
|
||||||
|
exit_func = true;
|
||||||
|
mode = TWINKLERANDOM;
|
||||||
|
getArgs();
|
||||||
|
getStatusJSON();
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
mqtt_client.publish(mqtt_outtopic, String("OK =twinkleRandom").c_str());
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_AMQTT
|
||||||
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =twinkleRandom").c_str());
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
|
#endif
|
||||||
|
});
|
||||||
|
|
||||||
|
server.on("/theaterchaseRainbow", []() {
|
||||||
|
exit_func = true;
|
||||||
|
mode = THEATERCHASERAINBOW;
|
||||||
|
getArgs();
|
||||||
|
getStatusJSON();
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchaseRainbow").c_str());
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_AMQTT
|
||||||
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchaseRainbow").c_str());
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
|
#endif
|
||||||
|
});
|
||||||
|
|
||||||
|
server.on("/tv", []() {
|
||||||
|
exit_func = true;
|
||||||
|
mode = TV;
|
||||||
|
getArgs();
|
||||||
|
getStatusJSON();
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
mqtt_client.publish(mqtt_outtopic, String("OK =tv").c_str());
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_AMQTT
|
||||||
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =tv").c_str());
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
|
#endif
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
server.on("/get_modes", []() {
|
server.on("/get_modes", []() {
|
||||||
getModesJSON();
|
getModesJSON();
|
||||||
|
@ -872,71 +873,76 @@ void loop() {
|
||||||
if (mode == SET_MODE) {
|
if (mode == SET_MODE) {
|
||||||
DBG_OUTPUT_PORT.printf("SET_MODE: %d %d\n", ws2812fx_mode, mode);
|
DBG_OUTPUT_PORT.printf("SET_MODE: %d %d\n", ws2812fx_mode, mode);
|
||||||
strip.setMode(ws2812fx_mode);
|
strip.setMode(ws2812fx_mode);
|
||||||
mode = SETSPEED;
|
prevmode = SET_MODE;
|
||||||
|
mode = SETCOLOR;
|
||||||
}
|
}
|
||||||
if (mode == OFF) {
|
if (mode == OFF) {
|
||||||
// strip.setColor(0,0,0);
|
|
||||||
// strip.setMode(FX_MODE_STATIC);
|
|
||||||
if(strip.isRunning()) strip.stop(); //should clear memory
|
if(strip.isRunning()) strip.stop(); //should clear memory
|
||||||
// mode = HOLD;
|
// mode = HOLD;
|
||||||
}
|
}
|
||||||
if (mode == ALL) {
|
|
||||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
|
||||||
strip.setMode(FX_MODE_STATIC);
|
|
||||||
mode = HOLD;
|
|
||||||
}
|
|
||||||
if (mode == SETCOLOR) {
|
if (mode == SETCOLOR) {
|
||||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||||
mode = HOLD;
|
mode = (prevmode == SET_MODE) ? SETSPEED : HOLD;
|
||||||
}
|
}
|
||||||
if (mode == SETSPEED) {
|
if (mode == SETSPEED) {
|
||||||
strip.setSpeed(convertSpeed(ws2812fx_speed));
|
strip.setSpeed(convertSpeed(ws2812fx_speed));
|
||||||
mode = HOLD;
|
mode = (prevmode == SET_MODE) ? BRIGHTNESS : HOLD;
|
||||||
}
|
}
|
||||||
if (mode == BRIGHTNESS) {
|
if (mode == BRIGHTNESS) {
|
||||||
strip.setBrightness(brightness);
|
strip.setBrightness(brightness);
|
||||||
|
if (prevmode == SET_MODE) prevmode == HOLD;
|
||||||
mode = HOLD;
|
mode = HOLD;
|
||||||
}
|
}
|
||||||
if (mode == WIPE) {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
if (mode == WIPE) {
|
||||||
strip.setMode(FX_MODE_COLOR_WIPE);
|
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_COLOR_WIPE);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == RAINBOW) {
|
}
|
||||||
strip.setMode(FX_MODE_RAINBOW);
|
if (mode == RAINBOW) {
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_RAINBOW);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == RAINBOWCYCLE) {
|
}
|
||||||
strip.setMode(FX_MODE_RAINBOW_CYCLE);
|
if (mode == RAINBOWCYCLE) {
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_RAINBOW_CYCLE);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == THEATERCHASE) {
|
}
|
||||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
if (mode == THEATERCHASE) {
|
||||||
strip.setMode(FX_MODE_THEATER_CHASE);
|
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_THEATER_CHASE);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == TWINKLERANDOM) {
|
}
|
||||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
if (mode == TWINKLERANDOM) {
|
||||||
strip.setMode(FX_MODE_TWINKLE_RANDOM);
|
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_TWINKLE_RANDOM);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == THEATERCHASERAINBOW) {
|
}
|
||||||
strip.setMode(FX_MODE_THEATER_CHASE_RAINBOW);
|
if (mode == THEATERCHASERAINBOW) {
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_THEATER_CHASE_RAINBOW);
|
||||||
}
|
mode = HOLD;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (mode == HOLD || mode == CUSTOM) {
|
if (mode == HOLD || mode == CUSTOM) {
|
||||||
if(!strip.isRunning()) strip.start();
|
if(!strip.isRunning()) strip.start();
|
||||||
if (exit_func) {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
exit_func = false;
|
if (exit_func) {
|
||||||
|
exit_func = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
if (mode == TV) {
|
||||||
|
if(!strip.isRunning()) strip.start();
|
||||||
|
tv();
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
if (mode == TV) {
|
|
||||||
if(!strip.isRunning()) strip.start();
|
|
||||||
tv();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only for modes with WS2812FX functionality
|
// Only for modes with WS2812FX functionality
|
||||||
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
if (mode != TV && mode != CUSTOM) {
|
if (mode != TV && mode != CUSTOM) {
|
||||||
|
#else
|
||||||
|
if (mode != CUSTOM) {
|
||||||
|
#endif
|
||||||
strip.service();
|
strip.service();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -963,4 +969,4 @@ void loop() {
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@ const char HOSTNAME[] = "McLighting01"; // Friedly hostname
|
||||||
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
|
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
|
||||||
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
|
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
|
||||||
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
||||||
|
#define ENABLE_LEGACY_ANIMATIONS
|
||||||
|
|
||||||
#if defined(USE_NEOANIMATIONFX) and defined(USE_WS2812FX)
|
#if defined(USE_NEOANIMATIONFX) and defined(USE_WS2812FX)
|
||||||
#error "Cant have both NeoAnimationFX and WS2812FX enabled. Choose either one."
|
#error "Cant have both NeoAnimationFX and WS2812FX enabled. Choose either one."
|
||||||
|
@ -85,17 +85,22 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
|
||||||
#define DBG_OUTPUT_PORT Serial // Set debug output port
|
#define DBG_OUTPUT_PORT Serial // Set debug output port
|
||||||
|
|
||||||
// List of all color modes
|
// List of all color modes
|
||||||
enum MODE { SET_MODE, HOLD, OFF, ALL, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM };
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM };
|
||||||
|
MODE mode = RAINBOW; // Standard mode that is active when software starts
|
||||||
|
bool exit_func = false; // Global helper variable to get out of the color modes when mode changes
|
||||||
|
#else
|
||||||
|
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, CUSTOM };
|
||||||
|
MODE mode = SET_MODE; // Standard mode that is active when software starts
|
||||||
|
#endif
|
||||||
|
|
||||||
MODE mode = RAINBOW; // Standard mode that is active when software starts
|
MODE prevmode = mode;
|
||||||
|
|
||||||
int ws2812fx_speed = 196; // Global variable for storing the delay between color changes --> smaller == faster
|
int ws2812fx_speed = 196; // Global variable for storing the delay between color changes --> smaller == faster
|
||||||
int brightness = 196; // Global variable for storing the brightness (255 == 100%)
|
int brightness = 196; // Global variable for storing the brightness (255 == 100%)
|
||||||
|
|
||||||
int ws2812fx_mode = 0; // Helper variable to set WS2812FX modes
|
int ws2812fx_mode = 0; // Helper variable to set WS2812FX modes
|
||||||
|
|
||||||
bool exit_func = false; // Global helper variable to get out of the color modes when mode changes
|
|
||||||
|
|
||||||
bool shouldSaveConfig = false; // For WiFiManger custom config
|
bool shouldSaveConfig = false; // For WiFiManger custom config
|
||||||
|
|
||||||
struct ledstate // Data structure to store a state of a single led
|
struct ledstate // Data structure to store a state of a single led
|
||||||
|
@ -135,4 +140,4 @@ LEDState main_color = { 255, 0, 0 }; // Store the "main color" of the strip use
|
||||||
byte KeyPressCount = 0;
|
byte KeyPressCount = 0;
|
||||||
byte prevKeyState = HIGH; // button is active low
|
byte prevKeyState = HIGH; // button is active low
|
||||||
boolean buttonState = false;
|
boolean buttonState = false;
|
||||||
#endif
|
#endif
|
|
@ -31,6 +31,12 @@ void getArgs() {
|
||||||
if (server.arg("m") != "") {
|
if (server.arg("m") != "") {
|
||||||
ws2812fx_mode = constrain(server.arg("m").toInt(), 0, strip.getModeCount() - 1);
|
ws2812fx_mode = constrain(server.arg("m").toInt(), 0, strip.getModeCount() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (server.arg("c").toInt() > 0) {
|
||||||
|
brightness = constrain((int) server.arg("c").toInt() * 2.55, 0, 255);
|
||||||
|
} else if (server.arg("p").toInt() > 0) {
|
||||||
|
brightness = constrain(server.arg("p").toInt(), 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
main_color.red = constrain(main_color.red, 0, 255);
|
main_color.red = constrain(main_color.red, 0, 255);
|
||||||
main_color.green = constrain(main_color.green, 0, 255);
|
main_color.green = constrain(main_color.green, 0, 255);
|
||||||
|
@ -74,7 +80,8 @@ void handleSetMainColor(uint8_t * mypayload) {
|
||||||
main_color.red = ((rgb >> 16) & 0xFF);
|
main_color.red = ((rgb >> 16) & 0xFF);
|
||||||
main_color.green = ((rgb >> 8) & 0xFF);
|
main_color.green = ((rgb >> 8) & 0xFF);
|
||||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
// strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||||
|
mode = SETCOLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetAllMode(uint8_t * mypayload) {
|
void handleSetAllMode(uint8_t * mypayload) {
|
||||||
|
@ -85,13 +92,16 @@ void handleSetAllMode(uint8_t * mypayload) {
|
||||||
main_color.green = ((rgb >> 8) & 0xFF);
|
main_color.green = ((rgb >> 8) & 0xFF);
|
||||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||||
|
|
||||||
for (int i = 0; i < strip.numPixels(); i++) {
|
// for (int i = 0; i < strip.numPixels(); i++) {
|
||||||
strip.setPixelColor(i, main_color.red, main_color.green, main_color.blue);
|
// strip.setPixelColor(i, main_color.red, main_color.green, main_color.blue);
|
||||||
}
|
// }
|
||||||
strip.show();
|
// strip.show();
|
||||||
DBG_OUTPUT_PORT.printf("WS: Set all leds to main color: [%u] [%u] [%u]\n", main_color.red, main_color.green, main_color.blue);
|
DBG_OUTPUT_PORT.printf("WS: Set all leds to main color: [%u] [%u] [%u]\n", main_color.red, main_color.green, main_color.blue);
|
||||||
exit_func = true;
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
mode = ALL;
|
exit_func = true;
|
||||||
|
#endif
|
||||||
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
|
mode = SET_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
||||||
|
@ -119,7 +129,9 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
||||||
strip.setPixelColor(led, ledstates[led].red, ledstates[led].green, ledstates[led].blue);
|
strip.setPixelColor(led, ledstates[led].red, ledstates[led].green, ledstates[led].blue);
|
||||||
strip.show();
|
strip.show();
|
||||||
}
|
}
|
||||||
exit_func = true;
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
exit_func = true;
|
||||||
|
#endif
|
||||||
mode = CUSTOM;
|
mode = CUSTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,64 +210,67 @@ void setModeByStateString(String saved_state_string) {
|
||||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetNamedMode(String str_mode) {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
exit_func = true;
|
void handleSetNamedMode(String str_mode) {
|
||||||
|
exit_func = true;
|
||||||
if (str_mode.startsWith("=off")) {
|
|
||||||
mode = OFF;
|
if (str_mode.startsWith("=off")) {
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
mode = OFF;
|
||||||
stateOn = false;
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
#endif
|
stateOn = false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=all")) {
|
||||||
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
|
mode = SET_MODE;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=wipe")) {
|
||||||
|
mode = WIPE;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=rainbow")) {
|
||||||
|
mode = RAINBOW;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=rainbowCycle")) {
|
||||||
|
mode = RAINBOWCYCLE;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=theaterchase")) {
|
||||||
|
mode = THEATERCHASE;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=twinkleRandom")) {
|
||||||
|
mode = TWINKLERANDOM;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=theaterchaseRainbow")) {
|
||||||
|
mode = THEATERCHASERAINBOW;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=tv")) {
|
||||||
|
mode = TV;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (str_mode.startsWith("=all")) {
|
#endif
|
||||||
mode = ALL;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=wipe")) {
|
|
||||||
mode = WIPE;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=rainbow")) {
|
|
||||||
mode = RAINBOW;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=rainbowCycle")) {
|
|
||||||
mode = RAINBOWCYCLE;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=theaterchase")) {
|
|
||||||
mode = THEATERCHASE;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=twinkleRandom")) {
|
|
||||||
mode = TWINKLERANDOM;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=theaterchaseRainbow")) {
|
|
||||||
mode = THEATERCHASERAINBOW;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=tv")) {
|
|
||||||
mode = TV;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleSetWS2812FXMode(uint8_t * mypayload) {
|
void handleSetWS2812FXMode(uint8_t * mypayload) {
|
||||||
mode = HOLD;
|
mode = HOLD;
|
||||||
|
@ -270,10 +285,16 @@ char* listStatusJSON() {
|
||||||
char json[255];
|
char json[255];
|
||||||
|
|
||||||
char modeName[30];
|
char modeName[30];
|
||||||
strncpy_P(modeName, (PGM_P)strip.getModeName(strip.getMode()), sizeof(modeName)); // copy from progmem
|
|
||||||
|
|
||||||
snprintf(json, sizeof(json), "{\"mode\":%d, \"ws2812fx_mode\":%d, \"ws2812fx_mode_name\":\"%s\", \"speed\":%d, \"brightness\":%d, \"color\":[%d, %d, %d]}",
|
// if (mode == SET_MODE) {
|
||||||
mode, strip.getMode(), modeName, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue);
|
strncpy_P(modeName, (PGM_P)strip.getModeName((uint8_t) ws2812fx_mode), sizeof(modeName)); // copy from progmem
|
||||||
|
snprintf(json, sizeof(json), "{\"mode\":%d, \"ws2812fx_mode\":%d, \"ws2812fx_mode_name\":\"%s\", \"speed\":%d, \"brightness\":%d, \"color\":[%d, %d, %d]}",
|
||||||
|
mode, ws2812fx_mode, modeName, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue);
|
||||||
|
// }else {
|
||||||
|
// strncpy_P(modeName, (PGM_P)strip.getModeName(strip.getMode()), sizeof(modeName)); // copy from progmem
|
||||||
|
// snprintf(json, sizeof(json), "{\"mode\":%d, \"ws2812fx_mode\":%d, \"ws2812fx_mode_name\":\"%s\", \"speed\":%d, \"brightness\":%d, \"color\":[%d, %d, %d]}",
|
||||||
|
// mode, strip.getMode(), modeName, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue);
|
||||||
|
// }
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,28 +524,30 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// = ==> Activate named mode
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
if (payload[0] == '=') {
|
// = ==> Activate named mode
|
||||||
// we get mode data
|
if (payload[0] == '=') {
|
||||||
String str_mode = String((char *) &payload[0]);
|
// we get mode data
|
||||||
|
String str_mode = String((char *) &payload[0]);
|
||||||
handleSetNamedMode(str_mode);
|
|
||||||
|
handleSetNamedMode(str_mode);
|
||||||
DBG_OUTPUT_PORT.printf("Activated mode [%u]!\n", mode);
|
|
||||||
webSocket.sendTXT(num, "OK");
|
DBG_OUTPUT_PORT.printf("Activated mode [%u]!\n", mode);
|
||||||
#ifdef ENABLE_MQTT
|
webSocket.sendTXT(num, "OK");
|
||||||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
#ifdef ENABLE_MQTT
|
||||||
#endif
|
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||||
#ifdef ENABLE_AMQTT
|
#endif
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
#ifdef ENABLE_AMQTT
|
||||||
#endif
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#endif
|
||||||
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
#endif
|
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#endif
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
#endif
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// $ ==> Get status Info.
|
// $ ==> Get status Info.
|
||||||
if (payload[0] == '$') {
|
if (payload[0] == '$') {
|
||||||
|
@ -597,13 +620,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkForRequests() {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
webSocket.loop();
|
void checkForRequests() {
|
||||||
server.handleClient();
|
webSocket.loop();
|
||||||
#ifdef ENABLE_MQTT
|
server.handleClient();
|
||||||
mqtt_client.loop();
|
#ifdef ENABLE_MQTT
|
||||||
#endif
|
mqtt_client.loop();
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -724,7 +749,8 @@ void checkForRequests() {
|
||||||
const char* state_in = root["state"];
|
const char* state_in = root["state"];
|
||||||
if (strcmp(state_in, on_cmd) == 0 and !(animation_on)) {
|
if (strcmp(state_in, on_cmd) == 0 and !(animation_on)) {
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
mode = ALL;
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
|
mode = SET_MODE;
|
||||||
}
|
}
|
||||||
else if (strcmp(state_in, off_cmd) == 0) {
|
else if (strcmp(state_in, off_cmd) == 0) {
|
||||||
stateOn = false;
|
stateOn = false;
|
||||||
|
@ -927,24 +953,26 @@ void checkForRequests() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// = ==> Activate named mode
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
if (payload[0] == '=') {
|
// = ==> Activate named mode
|
||||||
String str_mode = String((char *) &payload[0]);
|
if (payload[0] == '=') {
|
||||||
handleSetNamedMode(str_mode);
|
String str_mode = String((char *) &payload[0]);
|
||||||
DBG_OUTPUT_PORT.printf("MQTT: Activate named mode [%s]\n", payload);
|
handleSetNamedMode(str_mode);
|
||||||
#ifdef ENABLE_MQTT
|
DBG_OUTPUT_PORT.printf("MQTT: Activate named mode [%s]\n", payload);
|
||||||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
#ifdef ENABLE_MQTT
|
||||||
#endif
|
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||||
#ifdef ENABLE_AMQTT
|
#endif
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
#ifdef ENABLE_AMQTT
|
||||||
#endif
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#endif
|
||||||
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
#endif
|
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#endif
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
#endif
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// $ ==> Get status Info.
|
// $ ==> Get status Info.
|
||||||
if (payload[0] == '$') {
|
if (payload[0] == '$') {
|
||||||
|
@ -1408,4 +1436,4 @@ bool readStateFS() {
|
||||||
updateFS = false;
|
updateFS = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue