Skip to content

cemre/ha-background-video

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Home Assistant - Background Video

Instant vibes at home. Automatically turns on an Android TV, launches a YouTube video, and groups Sonos speakers.

Background Video, in action

Prerequisites

  • Home Assistant with a Sony Android TV added as a media player. (Any Android TV should work, but I haven't tested!)
  • Home Assistant Cloud, set up with Google Home
  • Sonos speakers (optional — for the speaker grouping feature)

Instructions

1: Enable ADB on your Sony TV

  1. On the TV, go to Settings > Device Preferences > About > Build
  2. Click Build 7 times to enable Developer Options
  3. Go to Settings > Device Preferences > Developer Options
  4. Enable USB Debugging

2: Install the Android Debug Bridge integration

  1. In Home Assistant, go to Settings > Devices & Services > Add Integration
  2. Search for Android TV Remote (or Android Debug Bridge) and install it
  3. Enter your TV's IP address when prompted
  4. Accept the pairing prompt that appears on the TV screen

3: Install the File Editor add-on

  1. Go to Settings > Add-ons > Add-on Store
  2. Search for File Editor and install it
  3. Start it and enable Show in sidebar

4: Upload video randomizer script

  1. Open File Editor from the sidebar
  2. Create a folder called python_scripts
  3. Upload get_random_youtube_video.py into python_scripts/

5: Add sensors

Open configuration.yaml in File Editor and append the file in this repo. This GitHub repo has 4 examples but you can add as many more as you want. Each sensor picks a random video ID from a YouTube channel or playlist feed. Replace the feed URLs with your own channels/playlists.

To get a feed URL:

  • Channel: https://www.youtube.com/feeds/videos.xml?channel_id=CHANNEL_ID
  • Playlist: https://www.youtube.com/feeds/videos.xml?playlist_id=PLAYLIST_ID
  • You can also pass individual video IDs as extra arguments (space-separated)

6: Add wrapper scripts

  1. Open scripts.yaml in File Editor (create it if it doesn't exist) and append the file in this repo.
  2. Update the entities for your TV and Sonos speakers.
  3. Add any new wrapper scripts, if you created additional sensors.

If you don't use scripts.yaml yet, make sure configuration.yaml includes it:

script: !include scripts.yaml

Find your entity IDs in Settings > Devices & Services > Entities (use the search box).

Variable What to put
tv Entity ID of your Sony TV, e.g. media_player.sony_tv
active_speaker Entity ID of your main Sonos speaker
group_speakers List of speaker entity IDs to group together

7: Expose scripts to voice assistants

For each wrapper script (e.g. "Background Video: Hiking"):

  1. Go to Settings > Automations & Scenes > Scripts
  2. Find the script > (...) on the right > Settings
  3. Voice Assistants > Turn on Expose
  4. Ensure Google Assistant is on
  5. Go back and save

This makes the script available to Google Home and other voice assistants.

8: Reload and test

  1. Go to Developer Tools > YAML and click Reload Scripts (and Reload Command Line to pick up the new sensors)
  2. Go to Settings > Scripts, find your wrapper script, and click Run
  3. Check Settings > System > Logs and filter for [Background Video] to see what's happening

9: Set up Google Home voice commands

Head to Home Settings > Works with Google > Home Assistant Cloud > Check for New Devices so the scripts you exposed are loaded.

Then, for each kind of video:

  1. Go to Automations > + to create a new automation
  2. Tap (...) in the top right > Previous household editor
  3. Tap New in the top right > Household
  4. Tap Add starter > Define a voice command and enter your phrase (e.g. "play hiking videos")
  5. Tap Add action > Adjust home devices, scroll to the very bottom, tap Add scenes, and find the Background Video: ... script

Repeat for each channel.

About

Home Assistant automation to play pleasant background videos and enhance the vibe of your home

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages