# \*SOLVED\* Chromecast app: Use variable in youtube URL

**URL:** <https://community.homey.app/t/solved-chromecast-app-use-variable-in-youtube-url/43051>\
**Category:** Apps\
**Created:** [February 15, 2021, 4:16pm UTC](https://community.homey.app/t/solved-chromecast-app-use-variable-in-youtube-url/43051 "2021-02-15T16:16:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichelS](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/michels/32/2162_2.png) [@MichelS](https://community.homey.app/u/MichelS)\
**Post date:** [February 15, 2021, 4:16pm UTC](https://community.homey.app/t/solved-chromecast-app-use-variable-in-youtube-url/43051/1 "2021-02-15T16:16:42Z")

</div>

I am trying to play a 1 hour Youtube video but starting at a random time in the clip.  
This because it’s linked to a zone active and re-starting the video is boring.

Youtube supports a T variable:  
‘([https://www.youtube.com/watch?v=Qz6XNSB0F3E&t=120](https://www.youtube.com/watch?v=Qz6XNSB0F3E&t=120))’  
This starts the video at 2 minutes.

Now I tried to use this URL in the Chromecast app, but it starts the video from the start and not at 2 minutes: `https://www.youtube.com/watch?v=Qz6XNSB0F3E&t=120`

The next step would be to randomize the start using:  
t={{round(random(0,120))}}

Does anyone know how to include the variable in the Chromecast app URL ?`

Flow Example: [Gedeelde Flow | Homey](https://homey.app/nl-nl/flow/p6HJBu/?fbclid=IwAR1rD544JMS2c8OBT6erQODcFYILeoALlIMOp_ZB-yiHsFpon9Drx1O6HVk)

Also tried to use a tag in the url and to let a viarable calculate the random number.  
But this also didn’t do the trick.  
Google TTS gives a random number, so that parts works, but the video starts at at 0 seconds:

 ![150596744_272433580965942_6596412734751255217_o](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/8/6821938d6c78a463d27b0a1f04a4dcef53200d08.jpeg)

---

<div class="post-metadata">

**Author:** ![Edwin\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/edwin_d/32/136417_2.png) [@Edwin\_D](https://community.homey.app/u/Edwin_D)\
**Post date:** [February 15, 2021, 4:26pm UTC](https://community.homey.app/t/solved-chromecast-app-use-variable-in-youtube-url/43051/2 "2021-02-15T16:26:06Z")

</div>

As far as I know Homey only allows number calculations, not string calculations. Google cast does allow tags for the URL, so what I would do is use Homeyscript to generate the complete URL and put it in a Better Logic variable (normal logic variables cannot be set from Homeyscript as far as I know). You then can use the variable as an URL you can cast.

---

<div class="post-metadata">

**Author:** ![b03tz](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/b03tz/32/35447_2.png) [@b03tz](https://community.homey.app/u/b03tz)\
**Post date:** [February 16, 2021, 7:35am UTC](https://community.homey.app/t/solved-chromecast-app-use-variable-in-youtube-url/43051/3 "2021-02-16T07:35:05Z")

</div>

It should at least be possible to maybe make a separate flow that does a calculation, put the result in a text variable and use that variable as your URL tag?

---

<div class="post-metadata">

**Author:** ![MichelS](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/michels/32/2162_2.png) [@MichelS](https://community.homey.app/u/MichelS)\
**Post date:** [February 16, 2021, 8:13am UTC](https://community.homey.app/t/solved-chromecast-app-use-variable-in-youtube-url/43051/4 "2021-02-16T08:13:58Z")

</div>

I think the app (developed by Athom) supports only one variable in the URL. And that is the video ID. A second variable is ignored ☹

Well not completely, because using a ?t= Instead of the &t= starts the player, loads the video, but doesn’t start to play.

If anyone reading this is willing to compile an url that could do the trick… I am looking forward to a reply 😊

---

<div class="post-metadata">

**Author:** ![MichelS](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/michels/32/2162_2.png) [@MichelS](https://community.homey.app/u/MichelS)\
**Post date:** [February 16, 2021, 10:13am UTC](https://community.homey.app/t/solved-chromecast-app-use-variable-in-youtube-url/43051/6 "2021-02-16T10:13:16Z")

</div>

Unfortunatly: [Not in the sourcecode](https://www.facebook.com/groups/homeyflow/permalink/1637165143141685/?comment_id=1637695239755342&reply_comment_id=1637717396419793)

Using a variable isn’t in the sourcecode of the app ☹

---

<div class="post-metadata">

**Author:** ![martijnpoppen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martijnpoppen/32/84849_2.png) [@martijnpoppen](https://community.homey.app/u/martijnpoppen)\
**Post date:** [February 16, 2021, 10:35am UTC](https://community.homey.app/t/solved-chromecast-app-use-variable-in-youtube-url/43051/7 "2021-02-16T10:35:50Z")

</div>

Youtube card only allows videoID.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/1/911d340a77be9cb46093efd5525122ab4dfcf298.png)

Also found an seek function , but seems like it’s not in use:  
 ![Screenshot 2021-02-16 at 10.35.46](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/e/fe439b1468ee42dddcfbc66460e20a2c0a61e25c.png)

Found the solution for playing YT at a specific time:  
Using an embed url it works:  
[https://homey.app/nl-nl/flow/ZI6pGu/](https://homey.app/nl-nl/flow/ZI6pGu/?fbclid=IwAR1DShABL37S3r-bB5eD9MPm3eED6OTOwFyRq0rm_bKPZ5LDINUMwAygoIw)

[https://homey.app/nl-nl/flow/wH7pGu/](https://homey.app/nl-nl/flow/wH7pGu/?fbclid=IwAR1mWA1fGYm_YW_EmNpqKgziighilFTqXU61O59-zB3k8PJCAIfMrc_tZd4)

---

<div class="post-metadata">

**Author:** ![MichelS](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/michels/32/2162_2.png) [@MichelS](https://community.homey.app/u/MichelS)\
**Post date:** [February 16, 2021, 11:01am UTC](https://community.homey.app/t/solved-chromecast-app-use-variable-in-youtube-url/43051/8 "2021-02-16T11:01:32Z")

</div>

You’re a magician 😃

IT WORKS! 😃  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/7/f71d4b1340f1b03fcaeef138af76be010dcda502.png)
