Routing different Sparrow sensors to different fields

If I wanted to route the values of two Sparrow sensors on the same gateway (i.e. common device id) to different fields in ThingSpeak, could I do something like this?:
(
$result := {
“api_key”: $TSkey,
“field1”: file = “20373358323650030028001b#air.qo” ? body.temperature,
“field2”: file = “20373358323650030028001b#air.qo” ? body.humidity,
“field3”: file = “20373358323650030028001b#air.qo” ? body.pressure,
“field4”: file = “20373358323650030028001b#air.qo” ? body.voltage
“field5”: file = “2037335832365003003f0048#air.qo” ? body.temperature,
“field6”: file = “2037335832365003003f0048#air.qo” ? body.humidity,
“field7”: file = “2037335832365003003f0048#air.qo” ? body.pressure,
“field8”: file = “2037335832365003003f0048#air.qo” ? body.voltage
};
)

This doesn’t actually work, but can it be tweaked to make it work? “TSkey” in this route is set as an environmental variable at the device level.

1 Like

Hi @rberkelm,

I always recommend testing out new JSONata expressions in the JSONata exerciser. I just ran your expression through (with a Sparrow Note of my own) and it worked great!

1 Like

Thanks Rob,
For some reason, my exerciser has a problem with the “#”?

Never mind, it works now. I just typed in the file name rather than pasting it in…
Thanks Rob!

1 Like

Yeah check the smart quotes too around all the strings - that may be messing with things!

1 Like