# Using node-red with Home Assistant

**URL:** https://discourse.nodered.org/t/using-node-red-with-home-assistant/76146
**Category:** General
**Tags:** home-assistant
**Created:** [5 March 2023 15:44 UTC](https://discourse.nodered.org/t/using-node-red-with-home-assistant/76146 "2023-03-05T15:44:32Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Lachimes29](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lachimes29/32/77136_2.png) [@Lachimes29](https://discourse.nodered.org/u/Lachimes29)
#### Post date: [5 March 2023 15:44 UTC](https://discourse.nodered.org/t/using-node-red-with-home-assistant/76146/1 "2023-03-05T15:44:32Z")

</div>

Hi all,

I have a call service node that works when I hard code the value of a youtube video but when I try to have it obtain the value from a query it does not work. The value does exist and when I obtain payload.items[1].contentDetails.videoId and display it via a debug node the video's ID shows correctly.

This is the data from my JSONATA window that does not work.  
{  
"media\_content\_type": "cast",  
"media\_content\_id": " { "app\_name": "youtube", "media\_id": "${payload.items[1].contentDetails.videoId}" }"

}

This is the code that works.  
{  
"media\_content\_type": "cast",  
"media\_content\_id": " { "app\_name": "youtube", "media\_id": "c66hr-IHOb8" }"

}

Many thanks.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [5 March 2023 20:22 UTC](https://discourse.nodered.org/t/using-node-red-with-home-assistant/76146/2 "2023-03-05T20:22:18Z")

</div>

Not a HA user  
but  
in tthe JSONata field input  
try

```auto
{
  "media_content_type": "cast",
  "media_content_id": { 
    "app_name": "youtube", 
    "media_id": $$.payload.items[1].contentDetails.videoId
  }
}

```

Or if "media\_id" needs to be a json string as in your working example, then

```auto
{
   "media_content_type": "cast",
   "media_content_id": $string({
       "app_name": "youtube",
       "media_id": $$.payload.items[1].contentDetails.videoId   
   })
}

```

---

<div class="post-metadata">

### Author: ![Lachimes29](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lachimes29/32/77136_2.png) [@Lachimes29](https://discourse.nodered.org/u/Lachimes29)
#### Post date: [5 March 2023 21:44 UTC](https://discourse.nodered.org/t/using-node-red-with-home-assistant/76146/3 "2023-03-05T21:44:33Z")

</div>

Thank you so much the last option worked 😀

---

<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: [19 March 2023 21:45 UTC](https://discourse.nodered.org/t/using-node-red-with-home-assistant/76146/4 "2023-03-19T21:45:16Z")

</div>

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