I had just copied the original, but decided to test out yours tonight (still new to esphome, learning as I go along). The main difference seems to be the inclusion of nested channels
data, since the outdoor sensor has 2 plus the “combined” sensor data.
I transposed the lambda code into JSON yaml as such:
json:
wifi: id(airgradient_wifi_signal).state
pm01: !lambda return to_string(id(pm_1_0).state);
pm02: !lambda return to_string(id(pm_2_5).state);
pm10: !lambda return to_string(id(pm_10_0).state);
pm003_count: !lambda return to_string(id(pm_0_3um).state);
atmp: !lambda return to_string(id(temp).state);
rhum: !lambda return to_string(id(humidity).state);
boot: "1"
channels:
"1":
pm01: !lambda return to_string(id(pm1_1_0).state);
pm02: !lambda return to_string(id(pm1_2_5).state);
pm10: !lambda return to_string(id(pm1_10_0).state);
pm003_count: !lambda return to_string(id(pm1_0_3um).state);
atmp: !lambda return to_string(id(pm1_temperature).state);
rhum: !lambda return to_string(id(pm1_humidity).state);
"2":
pm01: !lambda return to_string(id(pm2_1_0).state);
pm02: !lambda return to_string(id(pm2_2_5).state);
pm10: !lambda return to_string(id(pm2_10_0).state);
pm003_count: !lambda return to_string(id(pm2_0_3um).state);
atmp: !lambda return to_string(id(pm2_temperature).state);
rhum: !lambda return to_string(id(pm2_humidity).state);
However, that results in a compile error: Must be string, got <class 'esphome.helpers.OrderedDict'>. did you forget putting quotes around the value?.
… presumably around the object with 1
and 2
keys. I noticed that the original URL was sending the whole MAC address rather than the last 6 characters like yours did, so I’ve fixed that in my debug code. If that still doesn’t work, I’ll check to see if channels
is actually intended to be an array rather than object.