Merge pull request #11510 from s-hadinger/berry_mar_29

Berry fixes
This commit is contained in:
s-hadinger 2021-03-29 19:59:14 +02:00 committed by GitHub
commit d7d750c928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -213,7 +213,7 @@ char * copyStr(const char * str) {
}
const char ext_invalid_mem[] PROGMEM = "<--INVALID-->";
const uint32_t min_valid_ptr = 0x3FF00000; // addresses below this line are invalid
const uint32_t min_valid_ptr = 0x3F000000; // addresses below this line are invalid
int32_t ext_vsnprintf_P(char * buf, size_t buf_len, const char * fmt_P, va_list va) {
va_list va_cpy;

View File

@ -75,6 +75,7 @@ extern "C" {
int32_t top = be_top(vm); // Get the number of arguments
if (top == 2 && be_isstring(vm, 2)) { // only 1 argument of type string accepted
const char * command = be_tostring(vm, 2);
be_pop(vm, 2); // clear the stack before calling, because of re-entrant call to Berry in a Rule
ExecuteCommand(command, SRC_BERRY);
be_pushstring(vm, TasmotaGlobal.mqtt_data);
be_return(vm); // Return
@ -294,7 +295,7 @@ extern "C" {
if (data_present) {
// see ResponseLightState()
map_insert_bool(vm, "power", bitRead(TasmotaGlobal.power, light_num));
map_insert_bool(vm, "power", bitRead(TasmotaGlobal.power, light_num + Light.device - 1));
map_insert_int(vm, "bri", bri);
if (subtype >= LST_RGB) {
@ -364,9 +365,9 @@ extern "C" {
// power
if (map_find(vm, "power")) {
bool power = be_tobool(vm, -1);
bool current_power = bitRead(TasmotaGlobal.power, idx);
bool current_power = bitRead(TasmotaGlobal.power, idx + Light.device - 1);
if (power != current_power) { // only send command if needed
ExecuteCommandPower(Light.device + idx, (power) ? POWER_ON : POWER_OFF, SRC_BERRY);
ExecuteCommandPower(idx + Light.device, (power) ? POWER_ON : POWER_OFF, SRC_BERRY);
}
}
be_pop(vm, 1);