diff --git a/src/console.cpp b/src/console.cpp index 1f82c9941..964ee2cbf 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -264,6 +264,32 @@ static void setup_commands(std::shared_ptr & commands) { #endif */ +#ifdef EMSESP_DEBUG + // only for debug + commands->add_command( + ShellContext::MAIN, + CommandFlags::ADMIN, + string_vector{F_(set), "mqtt"}, + string_vector{"[on|off]"}, + [](Shell & shell, const std::vector & arguments) { + auto b = arguments.front(); + + if ((b == "on") || (b == "off")) { + to_app(shell).esp8266React.getMqttSettingsService()->updateWithoutPropagation([&](MqttSettings & settings) { + settings.enabled = (b == "on"); + shell.printfln("MQTT %s", settings.enabled ? "enabled" : "disabled"); + return StateUpdateResult::CHANGED; + }); + emsesp::EMSESP::mqtt_.reset_mqtt(); + } else { + shell.println("Must be on or off"); + } + }, + [](Shell & shell, const std::vector & current_arguments, const std::string & next_argument) -> std::vector { + return std::vector{"on", "off"}; + }); +#endif + commands->add_command(ShellContext::MAIN, CommandFlags::ADMIN, string_vector{F_(set), F_(wifi), F_(password)},