Created
October 9, 2023 00:12
-
-
Save jkerhin/8f9ca48d98ef3b89959e89b508d1b205 to your computer and use it in GitHub Desktop.
Silence Chromecast Speaker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Simple script to silence Tyler's Chromecast | |
| Documenting this for future me. This is the script I use to shut off Tyler's music | |
| each weekday morning when it's time to get up and get ready. Rock simple script, single | |
| line crontab. | |
| Crontab: | |
| 45 6 * * 1-5 /home/joe/.local/share/virtualenvs/chromecast-uUcxDOyh/bin/python /home/joe/projects/chromecast/silence_tyler_speaker.py | |
| Depends on the `pychromecast` library, see: | |
| https://github.com/home-assistant-libs/pychromecast | |
| """ | |
| import sys | |
| import pychromecast | |
| TY_CHROMECAST_NAME = "Tyler Bedroom speaker" | |
| devices, browser = pychromecast.get_listed_chromecasts( | |
| friendly_names=[TY_CHROMECAST_NAME] | |
| ) | |
| if len(devices) != 1: | |
| print("Couldn't find Tyler's Chromecast") | |
| print("Devices = ", devices) | |
| sys.exit(1) | |
| ty_chromecast = devices[0] | |
| # .wait() required to start worker thread | |
| ty_chromecast.wait() | |
| ty_chromecast.quit_app() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment