This commit is contained in:
proddy
2026-06-08 10:03:32 +02:00
parent 5c4dfcb9ae
commit 8a45e79071
5 changed files with 50 additions and 15 deletions

View File

@@ -75,7 +75,7 @@ MAKE_WORD_TRANSLATION(format_cmd, "factory reset EMS-ESP", "EMS-ESP auf Werksein
MAKE_WORD_TRANSLATION(watch_cmd, "watch incoming telegrams", "Beobachte eingehende Telegramme", "inkomende telegrammen bekijken", "visa inkommande telegram", "obserwuj przyczodzące telegramy", "se innkommende telegrammer", "surveiller les télégrammes entrants", "Gelen telegramları izle", "guardare i telegrammi in arrivo", "sledovať prichádzajúce telegramy", "sledovat příchozí telegramy")
MAKE_WORD_TRANSLATION(publish_cmd, "publish all to MQTT", "Publiziere MQTT", "publiceer alles naar MQTT", "publicera allt till MQTT", "opublikuj wszystko na MQTT", "Publiser alt til MQTT", "publier tout vers MQTT", "Hepsini MQTTye gönder", "pubblica tutto su MQTT", "zverejniť všetko na MQTT", "publikovat vše do MQTT")
MAKE_WORD_TRANSLATION(system_info_cmd, "show system info", "Zeige Systeminformationen", "toon systeemstatus", "visa systeminformation", "pokaż status systemu", "vis system status", "afficher les informations système", "Sistem Durumunu Göster", "visualizza stati di sistema", "zobraziť stav systému", "zobrazit informace o systému")
MAKE_WORD_TRANSLATION(schedule_cmd, "enable schedule item", "Aktiviere Zeitplanelemente", "activeer tijdschema item", "aktivera schemalagt objekt", "aktywuj wybrany harmonogram", "aktiver planlagt element", "activer élément programmé", "program öğesini etkinleştir", "abilitare l'elemento programmato", "povoliť položku plánovania", "povolit položku plánování")
MAKE_WORD_TRANSLATION(schedule_cmd, "enable/disable schedule item", "Aktiviere/Deaktiviere Zeitplanelemente", "activeer/deactiveer tijdschema item", "aktivera/deaktivera schemalagt objekt", "aktywuj/deaktywuj wybrany harmonogram", "aktiver/deaktiver planlagt element", "activer/deactiver élément programmé", "program öğesini etkinleştir/devre dışı bırak", "abilitare/disabilitare l'elemento programmato", "povoliť/deaktivovať položku plánovania", "povolit/deaktivovat položku plánování")
MAKE_WORD_TRANSLATION(command_cmd, "execute command", "Befehl ausführen", "opdracht uitvoeren", "kör kommando", "wykonaj polecenie", "kjør kommando", "exécuter commande", "komut çalıştır", "esegui comando", "vykonať príkaz", "provést příkaz")
MAKE_WORD_TRANSLATION(entity_cmd, "set custom value", "Sende eigene Entitäten", "verstuur custom waarde", "sätt ett eget värde", "wyślij własną wartość", "sett egendefinert verdi", "définir valeur personnalisée", "özel değer ayarla", "imposta valori personalizzati", "nastaviť vlastnú hodnotu", "nastavit vlastní hodnotu")
MAKE_WORD_TRANSLATION(commands_response, "get response", "Hole Antwort", "Verzoek om antwoord", "hämta svar", "uzyskaj odpowiedź", "få svar", "obtenir réponse", "yanıt al", "ottieni risposta", "získať odpoveď", "získat odpověď")

View File

@@ -350,6 +350,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::webCustomEntityService.load_test_data(); // custom entities
EMSESP::webCustomizationService.load_test_data(); // set customizations - this will overwrite any settings in the FS
EMSESP::temperaturesensor_.load_test_data(); // add temperature sensors
EMSESP::webCommandService.load_test_data(); // add command items
EMSESP::webSchedulerService.load_test_data(); // add scheduler data
shell.invoke_command("show values");
@@ -406,7 +407,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "scheduler") {
shell.printfln("Adding Scheduler items...");
// add some dummy entities
EMSESP::webCommandService.load_test_data();
EMSESP::webSchedulerService.load_test_data();
#ifdef EMSESP_STANDALONE
@@ -1116,6 +1117,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::webCustomEntityService.load_test_data(); // custom entities
EMSESP::webCustomizationService.load_test_data(); // set customizations - this will overwrite any settings in the FS
EMSESP::temperaturesensor_.load_test_data(); // add temperature sensors
EMSESP::webCommandService.load_test_data(); // add command items
EMSESP::webSchedulerService.load_test_data(); // run scheduler tests, and conditions
JsonDocument doc;
@@ -1379,6 +1381,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::webCustomEntityService.load_test_data(); // custom entities
EMSESP::webCustomizationService.load_test_data(); // set customizations - this will overwrite any settings in the FS
EMSESP::temperaturesensor_.load_test_data(); // add temperature sensors
EMSESP::webCommandService.load_test_data(); // add command items
EMSESP::webSchedulerService.load_test_data(); // run scheduler tests, and conditions
request.method(HTTP_GET);

View File

@@ -64,7 +64,7 @@ namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "hpmode"
// #define EMSESP_DEBUG_DEFAULT "shuntingyard"
// #define EMSESP_DEBUG_DEFAULT "src"
#define EMSESP_DEBUG_DEFAULT "led"
// #define EMSESP_DEBUG_DEFAULT "led"
#ifndef EMSESP_DEBUG_DEFAULT
#define EMSESP_DEBUG_DEFAULT "general"

View File

@@ -37,6 +37,10 @@ void WebCommandService::begin() {
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
snprintf(topic, sizeof(topic), "%s/#", F_(commands));
Mqtt::subscribe(EMSdevice::DeviceType::COMMAND, topic, nullptr);
#if defined(EMSESP_TEST)
load_test_data();
#endif
}
void WebCommands::read(WebCommands & webCommands, JsonObject root) {
@@ -67,9 +71,7 @@ StateUpdateResult WebCommands::update(JsonObject root, WebCommands & webCommands
Command::add(
EMSdevice::DeviceType::COMMAND,
webCommands.commandItems.back().name,
[](const char * value, const int8_t id) {
return EMSESP::webCommandService.executeCommand(value);
},
[](const char * value, const int8_t id) { return EMSESP::webCommandService.executeCommand(value); },
FL_(command_cmd),
CommandFlag::ADMIN_ONLY);
}
@@ -99,7 +101,7 @@ bool WebCommandService::executeCommand(const char * name) {
EMSESP::logger().warning("Command '%s' not found", name ? name : "");
return false;
}
return executeCommand(ci->name, ci->cmd, ci->value);
return executeCommand(ci->name, std::string(ci->cmd.c_str()), std::string(ci->value.c_str()));
}
// execute a command with explicit cmd and value strings
@@ -269,6 +271,7 @@ uint8_t WebCommandService::count_entities() {
#if defined(EMSESP_TEST)
void WebCommandService::load_test_data() {
Command::erase_device_commands(EMSdevice::DeviceType::COMMAND);
update([&](WebCommands & webCommands) {
webCommands.commandItems.clear();
@@ -284,6 +287,17 @@ void WebCommandService::load_test_data() {
strcpy(ci.name, "test_cmd2");
webCommands.commandItems.push_back(ci);
for (const auto & item : webCommands.commandItems) {
if (item.name[0] != '\0') {
Command::add(
EMSdevice::DeviceType::COMMAND,
item.name,
[](const char * value, const int8_t id) { return EMSESP::webCommandService.executeCommand(value); },
FL_(command_cmd),
CommandFlag::ADMIN_ONLY);
}
}
return StateUpdateResult::CHANGED;
});
}

View File

@@ -49,6 +49,10 @@ void WebSchedulerService::begin() {
#endif
}
#endif
#if defined(EMSESP_TEST)
load_test_data();
#endif
}
// this creates the scheduler file, saving it to the FS
@@ -454,6 +458,7 @@ void WebSchedulerService::scheduler_task(void * pvParameters) {
#if defined(EMSESP_TEST)
void WebSchedulerService::load_test_data() {
Command::erase_device_commands(EMSdevice::DeviceType::SCHEDULER);
update([&](WebScheduler & webScheduler) {
webScheduler.scheduleItems.clear();
@@ -479,6 +484,19 @@ void WebSchedulerService::load_test_data() {
webScheduler.scheduleItems.push_back(si);
for (const auto & item : webScheduler.scheduleItems) {
if (item.name[0] != '\0') {
Command::add(
EMSdevice::DeviceType::SCHEDULER,
item.name,
[name = std::string(item.name)](const char * value, const int8_t id) {
return EMSESP::webSchedulerService.command_setvalue(value, id, name.c_str());
},
FL_(schedule_cmd),
CommandFlag::ADMIN_ONLY);
}
}
return StateUpdateResult::CHANGED;
});
}