Skip to content

Commit 9983269

Browse files
committed
allow info command from mqtt, publish in topic:response
1 parent d891c7a commit 9983269

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/mqtt.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,12 @@ void Mqtt::on_message(const char * fulltopic, const char * payload, size_t len)
374374
char data_str[10];
375375
cmd_known = Command::call(mf.device_type_, command, Helpers::render_value(data_str, (float)data.as<float>(), 2), n);
376376
} else if (data.isNull()) {
377-
cmd_known = Command::call(mf.device_type_, command, "", n);
377+
DynamicJsonDocument resp(EMSESP_JSON_SIZE_XLARGE_DYN);
378+
JsonObject json = resp.to<JsonObject>();
379+
cmd_known = Command::call(mf.device_type_, command, "", n, json);
380+
if (cmd_known && json.size()) {
381+
Mqtt::publish(F("response"), resp.as<JsonObject>());
382+
}
378383
}
379384

380385
if (!cmd_known) {

0 commit comments

Comments
 (0)