Google Cast dashboard to nest display script has stopped working when called by automation (fine when ran directly)

Hi All
I have a script that uses the Google Cast service to display a dashboard on my nesst display:

service: cast.show_lovelace_view
data:
  entity_id: media_player.study_display
  dashboard_path: lovelace-study
  view_path: "0"

Until recently this worked fine. The script is called whenever I turn the lights on in the study.
Recently the study display has started showing an error message instead of the dashboard:
“Error: Error fetching Lovelace configuration: undefined”

This only happens when the automation triggers the script (when I turn on the lights). If I run the script directly using the HA UI it works fine.

Any ideas?

Try defining a view_path for the view.