# Complete beginner - how to extract specific values from yaml data

**URL:** <https://discourse.nodered.org/t/complete-beginner-how-to-extract-specific-values-from-yaml-data/68096>\
**Category:** General\
**Created:** [22 September 2022 20:01 UTC](https://discourse.nodered.org/t/complete-beginner-how-to-extract-specific-values-from-yaml-data/68096 "2022-09-22T20:01:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stain3565](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stain3565/32/68179_2.png) [@stain3565](https://discourse.nodered.org/u/stain3565)\
**Post date:** [22 September 2022 20:01 UTC](https://discourse.nodered.org/t/complete-beginner-how-to-extract-specific-values-from-yaml-data/68096/1 "2022-09-22T20:01:45Z")

</div>

I am using node red in Home Assistant and will need to use login data for many nodes that are stored in a yaml file.

This is my first node-red flow and I have managed to read a file and seemingly create a list of variable names and data.

 ![2022-09-22](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57ce83fbe891d1df2a31aeac5ae5f9e0337d4586.png)

```auto
[{"id":"07e3500b31e99eb0","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"4df03d8eb7fd62e1","type":"group","z":"07e3500b31e99eb0","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["f231967.0251a68","8f8f31b7.1f916","104b80e2.51068f","5326f9221556621a"],"x":94,"y":639,"w":712,"h":82},{"id":"f231967.0251a68","type":"inject","z":"07e3500b31e99eb0","g":"4df03d8eb7fd62e1","name":"YAML String","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":1}","payloadType":"str","x":210,"y":680,"wires":[["5326f9221556621a"]]},{"id":"8f8f31b7.1f916","type":"debug","z":"07e3500b31e99eb0","g":"4df03d8eb7fd62e1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":680,"wires":[]},{"id":"104b80e2.51068f","type":"yaml","z":"07e3500b31e99eb0","g":"4df03d8eb7fd62e1","property":"payload","name":"","x":530,"y":680,"wires":[["8f8f31b7.1f916"]]},{"id":"5326f9221556621a","type":"file in","z":"07e3500b31e99eb0","g":"4df03d8eb7fd62e1","name":"secrets","filename":"/config/secretstest.yaml","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":380,"y":680,"wires":[["104b80e2.51068f"]]}]

```

This has resulted in the following payload

`{"tplink_user":"email@gmail.com","tplink_password":"-password-","email_sender":"email2@gmail.com","email_receiver":"email3@gmail.com","email_password":"Bovril","tablet_info":"some text","homeassistant_email_user":"hubbahubba@gmail.com","homeassistant_email_password":"Boris","ifttt_key":"xxxxxxxxxx"}`

So now, if I want to get the value for email\_sender and homeassistant\_email\_password, and be able to use these values as variables in later nodes, how do I do this?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [22 September 2022 20:25 UTC](https://discourse.nodered.org/t/complete-beginner-how-to-extract-specific-values-from-yaml-data/68096/2 "2022-09-22T20:25:08Z")

</div>

> [@stain3565](#):
>
> So now, if I want to get the value for email\_sender and homeassistant\_email\_password, and be able to use these values as variables in later nodes, how do I do this?

If you look at the result in the sidebar, you can copy the path to the information that you want.

![help](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/85551abbbc1fc3662a13ec058d70d5eb68f9ae07.png)

Copy it and paste it in a change node, like this...

![pay](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0e5341647ed5e8cb30a2331d87cd926327dd0b85.jpeg)

and that should give you the data that you need.

Or to use as a variable in a function node...

`const emailSender = msg.payload.email_sender`

and do the same for the other password.

---

<div class="post-metadata">

**Author:** ![stain3565](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stain3565/32/68179_2.png) [@stain3565](https://discourse.nodered.org/u/stain3565)\
**Post date:** [22 September 2022 21:41 UTC](https://discourse.nodered.org/t/complete-beginner-how-to-extract-specific-values-from-yaml-data/68096/3 "2022-09-22T21:41:31Z")

</div>

Thanks. I will give that a go and update this when i have tried it.

I have noticed that i seem to have had the email addresses changed since I posted, probably for security reasons. If it was human intervention, they were not real and were just gibberish that came into my mind when posting. I will stick with the [emailx@email.com](mailto:emailx@email.com) firmat if that is posting standards. Not just a novice at node red but also posting on this forum!

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [22 September 2022 21:54 UTC](https://discourse.nodered.org/t/complete-beginner-how-to-extract-specific-values-from-yaml-data/68096/4 "2022-09-22T21:54:31Z")

</div>

> [@stain3565](#):
>
> I have noticed that i seem to have had the email addresses changed since I posted, probably for security reasons

Yes. that was me!  
You said that you are a complete beginner, and an alarm sounded when I saw the "tplink\_password" & email addresses.  
Now we are doubly sure that your privacy is protected 😆

Paul - Moderator

---

<div class="post-metadata">

**Author:** ![piwi447](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/piwi447/32/67335_2.png) [@piwi447](https://discourse.nodered.org/u/piwi447)\
**Post date:** [23 September 2022 03:38 UTC](https://discourse.nodered.org/t/complete-beginner-how-to-extract-specific-values-from-yaml-data/68096/5 "2022-09-23T03:38:11Z")

</div>

You said you will use these mail and password multiple times in future.  
My advice would be to store them in a context variable.  
You can use flow context or global context.  
There are functions to set and retrieve context variables in change node and in function node…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 October 2022 03:38 UTC](https://discourse.nodered.org/t/complete-beginner-how-to-extract-specific-values-from-yaml-data/68096/6 "2022-10-07T03:38:11Z")

</div>

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