From 663cb33f4bb9a99353d7fcc98d9498fc691ef70c Mon Sep 17 00:00:00 2001 From: Patrick Amrhein Date: Mon, 3 Jun 2024 21:14:55 +0200 Subject: [PATCH] powermeter mqtt json --- src/plugins/zeroExport/powermeter.h | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/plugins/zeroExport/powermeter.h b/src/plugins/zeroExport/powermeter.h index d590aae1..a3880e4b 100644 --- a/src/plugins/zeroExport/powermeter.h +++ b/src/plugins/zeroExport/powermeter.h @@ -219,23 +219,18 @@ class powermeter { float power = 0.0; -/// TODO: Json aktivieren -// //TODO: datajson 100 enough? -// // this if-statement need to check if value contains a json object. -// // is it so, then deserialize it and get the values (Shelly GEN2) -// DynamicJsonDocument datajson(100); -// if (!deserializeJson(datajson, obj["val"])) -// { -// switch (mCfg->groups[group].pm_target) { -// case 0: power = datajson["a_act_power"]; break; -// case 1: power = datajson["b_act_power"]; break; -// case 2: power = datajson["c_act_power"]; break; -// case 3: power = datajson["total_act_power"]; break; -// } -// } else { -// //TODO: check if parse is possible here? Is that right? + DynamicJsonDocument datajson(512); + if (!deserializeJson(datajson, obj["val"])) + { + switch (mCfg->groups[group].pm_target) { + case 0: power = datajson["a_act_power"]; break; + case 1: power = datajson["b_act_power"]; break; + case 2: power = datajson["c_act_power"]; break; + case 3: power = datajson["total_act_power"]; break; + } + } else { power = (float)obj["val"]; -// } + } bufferWrite(power, group); mCfg->groups[group].power = power; // TODO: join two sites together (PM & MQTT)