About eight years ago we purchased a small Samsung "Smart TV". At the time we thought it was very clever as it has an ethernet connection which allowed us to use an inbuilt web browser and iPlayer. Subsequently it was used as a computer screen and to play media from a DLNA server.
I now want to integrate it with Home Assistant so that we can start and control videos as we do for music. Unfortunately the Smart TV is not smart enough for this so I purchased a Chromecast to help it.
Chromecast installation and testing
As expected there is a slick installation procedure and I soon have the Chromecast working on HDMI with the usual apps such as Netflix, ITVhub available.
Chromecast provides extra connectivity capabilities.
We can easily cast youtube or iplayer from the phone to Chromecast.
On the ipad we can cast from youtube, vlc or iplayer.
On the PC we can cast a chrome browser session to the TV allowing us to see whatever is displayed or playing in the browser. Alternatively you can cast videos from the youtube app or vlc.
All these facilities are great but I probably wouldn't use them much in practice, so I now need to see what extras Home Assistant can offer.
Home Assistant
HA has a Google Cast integration built in and uses it to send speech or music to the Google Nest mini. As far as HA is concerned the TV, with Chromecast attached, is just another casting device.
Using the "Browse Media" button on the card for the TV you can select a video from the DLNA server or local media and play it on the TV. This is a great start, we can already play videos of our choice and it is as simple to use from HA as it is selecting DLNA directly on the TV.
Looking at the sample in Google Cast integration it is easy to setup a script to cast a video to the TV. The service is media_player.play_media, the target is media_player.john_study_tv and you just need to provide a URL and type for the media content. Running this script causes the video to play. Now that I have a script I can use a webhook or Google Assistant command to initiate the video so I have the basis of a solution.
Clearly it is rather limiting if I have to setup a script for each video I want to play so I setup a helper, called xmas_anthem for testing. I can can setup a number of valid options for xmas_anthem and set the value on a dashboard card. Within the script I can now test input_select.xmas_anthem to determine which video to play.
You can also
play youtube videos by specifiying suitable media_content details:
Since our first test was to play a video from DLNA it must also be possible to specify a DLNA video as the media_content. This doesn't seem to be simple. When looking at a DLNA video playing I can see that the media_content_id is a URL containing a numeric value (5240.mkv in the example shown below) rather than a filename. To determine these values I would need to interrogate the DLNA server. I have a python script which sort of does this but it doesn't work well yet.
Conclusion
I now have the tools I need to play videos on a TV, namely ChromeCast and Home Assistant scripts. The next stage is to work out what videos I want and setup a webpage or voice commands to play them.