diff --git a/CHANGELOG.md b/CHANGELOG.md index e6f8a03b2..1b2050d40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. ### Changed - Initial ``DisplayMode`` from 1 to 0 and ``DisplayDimmmer`` from 10% to 50% (#19138) - ESP32 Framework (Core) from v2.0.10 to v2.0.11 +- Berry `mqtt.publish` now distinguishes between `string` and `bytes` ### Fixed - Initial battery level percentage (#19160) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_mqtt.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_mqtt.ino index 16139a295..6cb6c4e2e 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_mqtt.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_mqtt.ino @@ -33,8 +33,10 @@ extern "C" { bool retain = false; int32_t payload_start = 0; int32_t len = -1; // send all of it + bool is_binary = be_isbytes(vm, 3); // is this a binary payload (or false = string) if (top >= 4) { retain = be_tobool(vm, 4); } if (top >= 5) { + if (!is_binary) { be_raise(vm, "argument_error", "start and len are not allowed with string payloads"); } payload_start = be_toint(vm, 5); if (payload_start < 0) payload_start = 0; } @@ -60,7 +62,7 @@ extern "C" { be_pop(vm, be_top(vm)); // clear stack to avoid any indirect warning message in subsequent calls to Berry - MqttPublishPayload(topic, payload, len, retain); + MqttPublishPayload(topic, payload, is_binary ? len : 0 /*if string don't send length*/, retain); be_return_nil(vm); // Return }