JSONATA - Lookup data in a change node?


My inverter sends in a heap of data which i am parsing with the Buffer Parser node - one of those variables is battery mode - which comes in as a number - mode 1 = charging, mode 2 = discharging

I am currently using a change node to set this (and other things as global variables for use throughout my flows.

Is there a way to take that incoming stream and on the fly convert that from Mode 1 to Mode Charging and store that in the Global varisable instead ?

This way when i populate my dashboard i have it there rather than using a function node to look it up and change it

And then when i put it on the dashboard i use the text node

Which means i need another change node before the Dashboard Text node


Try a ternary expression

$$.payload.battery_mode = 1 ? "Charging" : 
$$.payload.battery_mode = 2 ? "Discharging" : "Error"

[edit corrected missing payload property ]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.