Script to restart Google Chromecast

I am trying to create a script to restart the Google Chromecast app on a regular basis as it keeps disconnecting from devices. This is what I have:

const appName = 'Google ChromeCast';
const app = await Homey.apps.getApp({ name: appName });
await app.restart({ id: 'homey:app:com.google.chromecast@2.0.0' });

But I get this error:
:x: Script Error
:warning: RestartChromeCast.js:3
await app.restart({ id: homey:app:com.google.chromecast@2.0.0 });
^

SyntaxError: Unexpected token ‘:’
at new Script (node:vm:100:7)
at HomeyScriptApp.runScript (/app.js:483:23)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.runScript (/api.js:30:22)

The right app id can be found here (enter an app’s device name)

Or just take a look at the app store URL; the last part of the app id is the ‘reversed URL’ right after /app/

https://homey.app/en-gb/app/com.google.chromecast/Google-Chromecast/

But why not use a flow (I’m on my mobile, sorry, so ‘glue’ the screenshots from left to right)

Explained: When the app is paused or crashed, the Chromecast card will be unavailable.
In that case, the flow restarts Chromecast

1 Like

Indeed, remove the @2.0.0 part.