Hello, relative newbie to Node-Red, but having followed the various tutorials and searched what I can on here I have a few pages up and running.
My latest issue, that I am hoping the collective can assit with, is the code for looking up an id number in an array and returning various corresponding values.
The msg object/array I receive from an API request is as follows:
{
"label": "MiHome",
"data": [
{
"id": 260882,
"name": "UPS",
"on": 1,
"power": 116
},
{
"id": 253105,
"name": "PC",
"on": 1,
"power": null
},
{
"id": 253110,
"name": "TV",
"on": 0,
"power": null
},
{
"id": 253593,
"name": "Desk",
"on": 1,
"power": null
},
{
"id": 257639,
"name": "Printer",
"on": 0,
"power": 0
},
{
"id": 260431,
"name": "Fan",
"on": 0,
"power": null
},
{
"id": 260448,
"name": "Socket",
"on": 0,
"power": 0
},
]
}
I want to then be able to lookup the ID number and return the on/off state (0 or 1) and the power reading (where applicable). I've tried searching the forum, and lokoing at the JSONata pages but can't seem to get anything to work?
It would be great if someone can point me in the right direction of the way to go about this?
Many thanks
Olly