Skip to content

Commit f00d3ea

Browse files
authored
Merge pull request #176 from MallocArray/ppt_arduinojson_fix
fix for ppt model and arduinojson changes
2 parents 6dbed41 + 92b6058 commit f00d3ea

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

packages/airgradient_api_esp32-c3_dual_pms5003t.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ interval:
1919
# https://github.com/ajfriesen/ESPHome-AirGradient/blob/main/air-gradient-open-air.yaml
2020
# https://arduinojson.org/v7/assistant
2121
body: !lambda |
22-
String jsonString;
23-
StaticJsonDocument<1024> doc;
22+
std::string jsonString;
23+
JsonDocument doc;
2424
2525
doc["wifi"] = id(wifi_dbm).state;
2626
@@ -36,17 +36,17 @@ interval:
3636
// Uptime in minutes as the boot value
3737
doc["boot"] = to_string(round(id(device_uptime).state/60));
3838
39-
JsonObject channels = doc.createNestedObject("channels");
39+
JsonObject channels = doc["channels"].to<JsonObject>();
4040
41-
JsonObject channels_1 = channels.createNestedObject("1");
41+
JsonObject channels_1 = channels["1"].to<JsonObject>();
4242
channels_1["pm01"] = to_string(id(pm_1_0).state);
4343
channels_1["pm02"] = to_string(id(pm_2_5).state);
4444
channels_1["pm10"] = to_string(id(pm_10_0).state);
4545
channels_1["pm003Count"] = to_string(id(pm_0_3um).state);
4646
channels_1["atmp"] = to_string(id(temp).state);
4747
channels_1["rhum"] = to_string(id(humidity).state);
4848
49-
JsonObject channels_2 = channels.createNestedObject("2");
49+
JsonObject channels_2 = channels["2"].to<JsonObject>();
5050
channels_2["pm01"] = to_string(id(pm_1_0_2).state);
5151
channels_2["pm02"] = to_string(id(pm_2_5_2).state);
5252
channels_2["pm10"] = to_string(id(pm_10_0_2).state);
@@ -57,10 +57,7 @@ interval:
5757
// Serialize the JSON document into the string
5858
serializeJson(doc, jsonString);
5959
60-
// Convert String to std::string
61-
std::string stdJsonString(jsonString.c_str());
62-
63-
return stdJsonString;
60+
return jsonString;
6461
6562
6663
switch:

packages/airgradient_d1_mini_board.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
substitutions:
2-
config_version: 5.3.2
2+
config_version: 5.3.3
33

44
esphome:
55
name: "${name}"

packages/airgradient_esp32-c3_board-arduino.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
substitutions:
2-
config_version: 5.3.2
2+
config_version: 5.3.3
33

44
esphome:
55
name: "${name}"

packages/airgradient_esp32-c3_board.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
substitutions:
2-
config_version: 5.3.2
2+
config_version: 5.3.3
33

44
esphome:
55
name: "${name}"

0 commit comments

Comments
 (0)