updates to scheduler for immediate commands #1893

This commit is contained in:
proddy
2024-07-27 15:04:22 +02:00
parent 008e2f0c7a
commit 0edb5c0fd9
10 changed files with 202 additions and 190 deletions

View File

@@ -148,8 +148,8 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
const char * device_p = device_s;
const char * data_p = nullptr;
strlcpy(device_s, d, device_end - d + 1);
data_p = device_end + 1;
int8_t id_d = -1;
data_p = device_end + 1;
int8_t id_d = -1;
uint8_t device_type = EMSdevice::device_name_2_device_type(device_p);
if (device_type > EMSdevice::DeviceType::BOILER) {
data_p = parse_command_string(data_p, id_d);

View File

@@ -411,7 +411,8 @@ uint32_t Helpers::hextoint(const char * hex) {
// get current character then increment
char byte = *hex++;
// transform hex character to the 4bit equivalent number, using the ascii table indexes
if (byte == ' ') byte = *hex++; // skip spaces
if (byte == ' ')
byte = *hex++; // skip spaces
if (byte >= '0' && byte <= '9')
byte = byte - '0';
else if (byte >= 'a' && byte <= 'f')

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.7.0-dev.27"
#define EMSESP_APP_VERSION "3.7.0-dev.28"

View File

@@ -198,7 +198,7 @@ bool WebSchedulerService::get_value_info(JsonObject output, const char * cmd) {
output["onchange"] = scheduleItem.time;
} else if (scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_TIMER) {
output["timer"] = scheduleItem.time;
} else if (scheduleItem.flags != 0){
} else if (scheduleItem.flags != 0) {
output["time"] = scheduleItem.time;
}
output["command"] = scheduleItem.cmd;
@@ -489,7 +489,7 @@ void WebSchedulerService::loop() {
}
for (ScheduleItem & scheduleItem : *scheduleItems_) {
if (scheduleItem.active && scheduleItem.flags == 0) {
if (scheduleItem.active && scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_IMMEDIATE) {
command(scheduleItem.name.c_str(), scheduleItem.cmd, compute(scheduleItem.value));
scheduleItem.active = false;
}

View File

@@ -22,10 +22,18 @@
#define EMSESP_SCHEDULER_FILE "/config/emsespScheduler.json"
#define EMSESP_SCHEDULER_SERVICE_PATH "/rest/schedule" // GET and POST
// bit flags for the schedule items. Matches those in interface/src/app/main/SchedulerDialog.tsx
// 0-127 (0->0x7F) is day schedule
// 128/0x80 is timer
// 129/0x81 is on change
// 130/0x82 is on condition
// 132/0x84 is immediate
#define SCHEDULEFLAG_SCHEDULE_TIMER 0x80 // 7th bit for Timer
#define SCHEDULEFLAG_SCHEDULE_ONCHANGE 0x81 // 7th+1st bit for OnChange
#define SCHEDULEFLAG_SCHEDULE_CONDITION 0x82 // 7th+2nd bit for Condition
#define MAX_STARTUP_RETRIES 3 // retry the start-up commands x times
#define SCHEDULEFLAG_SCHEDULE_IMMEDIATE 0x84 // 7th+3rd bit for Condition
#define MAX_STARTUP_RETRIES 3 // retry the start-up commands x times
namespace emsesp {