calculate command ids from tag names

This commit is contained in:
MichaelDvP
2023-01-02 15:29:33 +01:00
parent 56b5739cfc
commit 4aa9d11574

View File

@@ -131,15 +131,15 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
id_n = input["hc"]; id_n = input["hc"];
} else if (input.containsKey("wwc")) { } else if (input.containsKey("wwc")) {
id_n = input["wwc"]; id_n = input["wwc"];
id_n += 8; // wwc1 has id 9 id_n += DeviceValueTAG::TAG_WWC1 - DeviceValueTAG::TAG_HC1; // wwc1 has id 9
} else if (input.containsKey("id")) { } else if (input.containsKey("id")) {
id_n = input["id"]; id_n = input["id"];
} else if (input.containsKey("ahs")) { } else if (input.containsKey("ahs")) {
id_n = input["ahs"]; id_n = input["ahs"];
id_n += 18; // ahs1 has id 19 id_n += DeviceValueTAG::TAG_AHS1 - DeviceValueTAG::TAG_HC1; // ahs1 has id 19
} else if (input.containsKey("hs")) { } else if (input.containsKey("hs")) {
id_n = input["hs"]; id_n = input["hs"];
id_n += 19; // hs1 has id 20 id_n += DeviceValueTAG::TAG_HS1 - DeviceValueTAG::TAG_HC1; // hs1 has id 20
} }
} }
@@ -210,10 +210,10 @@ const char * Command::parse_command_string(const char * command, int8_t & id) {
id = command[2] - '0'; id = command[2] - '0';
command += 3; command += 3;
} else if (!strncmp(lowerCmd, "wwc", 3) && command[3] == '1' && command[4] == '0') { } else if (!strncmp(lowerCmd, "wwc", 3) && command[3] == '1' && command[4] == '0') {
id = 18; id = DeviceValueTAG::TAG_WWC10 - DeviceValueTAG::TAG_HC1 + 1; //18;
command += 5; command += 5;
} else if (!strncmp(lowerCmd, "wwc", 3) && command[3] >= '1' && command[3] <= '9') { } else if (!strncmp(lowerCmd, "wwc", 3) && command[3] >= '1' && command[3] <= '9') {
id = command[3] - '1' + 9; id = command[3] - '1' + DeviceValueTAG::TAG_WWC1 - DeviceValueTAG::TAG_HC1 + 1; //9;
command += 4; command += 4;
} else if (!strncmp(lowerCmd, "id", 2) && command[2] == '1' && command[3] >= '0' && command[3] <= '9') { } else if (!strncmp(lowerCmd, "id", 2) && command[2] == '1' && command[3] >= '0' && command[3] <= '9') {
id = command[3] - '0' + 10; id = command[3] - '0' + 10;
@@ -222,13 +222,13 @@ const char * Command::parse_command_string(const char * command, int8_t & id) {
id = command[2] - '0'; id = command[2] - '0';
command += 3; command += 3;
} else if (!strncmp(lowerCmd, "ahs", 3) && command[3] >= '1' && command[3] <= '1') { // only ahs1 for now } else if (!strncmp(lowerCmd, "ahs", 3) && command[3] >= '1' && command[3] <= '1') { // only ahs1 for now
id = command[3] - '1' + 19; id = command[3] - '1' + DeviceValueTAG::TAG_AHS1 - DeviceValueTAG::TAG_HC1 + 1; // 19;
command += 4; command += 4;
} else if (!strncmp(lowerCmd, "hs", 2) && command[2] == '1' && command[3] >= '0' && command[3] <= '6') { } else if (!strncmp(lowerCmd, "hs", 2) && command[2] == '1' && command[3] >= '0' && command[3] <= '6') {
id = command[3] - '0' + 29; id = command[3] - '0' + DeviceValueTAG::TAG_HS10 - DeviceValueTAG::TAG_HC1 + 1; //29;
command += 4; command += 4;
} else if (!strncmp(lowerCmd, "hs", 2) && command[2] >= '1' && command[2] <= '9') { } else if (!strncmp(lowerCmd, "hs", 2) && command[2] >= '1' && command[2] <= '9') {
id = command[2] - '1' + 20; id = command[2] - '1' + DeviceValueTAG::TAG_HS1 - DeviceValueTAG::TAG_HC1 + 1; //20;
command += 3; command += 3;
} }
// remove separator // remove separator