I have a solution to this problem. However, it requires a few changes.
- It requires custom code in the cast receiver app that is running in chromecast
- To send the required messages to the receiver app, pychromecast needs to be extended
- In order to play also local media in a custom receiver app, the receiver app needs to be hosted in the private network. Personally, I serve it directly from home assistant
- In order to serve a custom receiver app from the private network, it requires a smart redirect service which redirects chromecast from a public cast URL back into the private network.
I have created all of the above four parts and an example script that shows how to use it.
I have published everything in the following repository: GitHub - Lamarqe/cast-custom-receiver
I have also reached out to the maintainer of pychromecast as I would like to merge the pychromecast extensions back to the main source tree of pychromecast. I am currently waiting for feedback.