Using node-red with Home Assistant

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.

Not a HA user
but
in tthe JSONata field input
try

{
  "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

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

Thank you so much the last option worked :grinning:

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