Fix ESP32 rules operation priority regression from v13.3.0.4 (#22636)

This commit is contained in:
Theo Arends 2024-12-12 15:34:43 +01:00
parent 6268066bac
commit 620fade73c
3 changed files with 9 additions and 2 deletions

View File

@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
### Changed ### Changed
### Fixed ### Fixed
- ESP32 rules operation priority regression from v13.3.0.4 (#22636)
### Removed ### Removed

View File

@ -123,5 +123,6 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
### Changed ### Changed
### Fixed ### Fixed
- ESP32 rules operation priority regression from v13.3.0.4 [#22636](https://github.com/arendst/Tasmota/issues/22636)
### Removed ### Removed

View File

@ -1687,14 +1687,19 @@ float evaluateExpression(const char * expression, unsigned int len) {
while (index < operators_size) { while (index < operators_size) {
if (priority == pgm_read_byte(kExpressionOperatorsPriorities + operators[index])) { // Need to calculate the operator first if (priority == pgm_read_byte(kExpressionOperatorsPriorities + operators[index])) { // Need to calculate the operator first
// Get current object value and remove the next object with current operator // Get current object value and remove the next object with current operator
// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: index %d, v1 '%4_f', v2 '%4_f', op %d"), index, &object_values[index], &object_values[index + 1], operators[index]);
va = calculateTwoValues(object_values[index], object_values[index + 1], operators[index]); va = calculateTwoValues(object_values[index], object_values[index + 1], operators[index]);
uint32_t i = index; uint32_t i = index;
while (i <= operators_size) { while (i <= operators_size) {
operators[i++] = operators[i]; // operators.remove(index) // operators[i++] = operators[i]; // operators.remove(index) - Fails on ESP32 (#22636)
operators[i] = operators[i +1]; // operators.remove(index)
i++;
object_values[i] = object_values[i +1]; // object_values.remove(index + 1) object_values[i] = object_values[i +1]; // object_values.remove(index + 1)
} }
operators_size--; operators_size--;
object_values[index] = va; // Replace the current value with the result object_values[index] = va; // Replace the current value with the result
// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Intermediate '%4_f'"), &object_values[index]); // AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Intermediate '%4_f'"), &object_values[index]);