How do I extract data from an object inside an object?

#1

I have an Alexa Local node that provides this data when I tell Alexa: "Set the landing light to 50%"

msg.payload : string[54]
"{"data":{"entity_id":"light.landing","brightness":50}}"

Alexa responds with a brightness value from 0 to 100%, but the light I am controlling needs a value from 0 to 255. The Map node should do this, but how, please, do I extract the value of brightness?

Thanks

0 Likes

#2

Hi @SteveMann

The docs have a section of working with messages: https://nodered.org/docs/user-guide/messages

It covers understanding the structure of your message, the difference between a JSON string and a parsed object, and how to identify the path to address any message element.

Rather than repeat that content here, please have a read, and ask if anything isn't clear.

Nick

0 Likes