Node Red - Extracting data from msg object

I have a msg object with the following data :

msg.payload : Object
object
devId: "10470280dc4f22exxxxx"
dps: object
1: true
t: 1578185591

I need to turn an input_boolean on or off based on the value of 1 : true , so that 1: true = on and 1: false = off .

A bit lost here as I have no idea how to get this info from my node . It’s a smart plug and it should output those values whenever the state is changed between on and off (when i press power on or off on the plug or use my HA switch) .

Anyone knows how to extract this info whenever the node outputs this data ?

Thanks

It should be
msg.payload.1 from what you have posted

Use a debug node to confirm
Change tbe debug node to complete message output
Expand the output in the debug window
Use the copy path button in the debug window to copy the correct path.

1 Like

Thanks for the hints @Harry13 .

The complete msg output is this :

msg : Object
object
data: object
name: "extensao sala"
ip: "192.168.0.1xx"
id: "10470280dc4f22edxxxx"
available: true
commandByte: 8
payload: object
devId: "10470280dc4f22edxxxx"
dps: object
1: true
t: 1578187738
_msgid: "70f03ec5.ae73d"

If I copy the path of dps (where the 1: true data is) I get payload.dps .

Should I just get use a node do get msg.payload.dps output ?

It’s just msg.payload.dps.1

1 Like

Thanks buddy, got the switch working now :slight_smile: :+1: