PiChromecast
Library for MicroPython to communicate with the Google Chromecast.
Install
Tools > Manage packages...
or copy and paste code
https://github.com/GitHub30/pichromecast/blob/main/pichromecast.py
Usage
from pichromecast import play_url
play_url('https://nyanpass.com/nyanpass.mp3', '192.168.10.101')
Text to Speech
from pichromecast import play_url, create_url
play_url(create_url('hello world', 'en'), '192.168.10.101')
# https://gist.github.com/SpotlightKid/eca9b00239104e8c599b86635f62ab73#file-urlencode-py
from urlencode import urlencode
from pichromecast import play_url
url = 'https://translate.google.com/translate_tts?client=tw-ob&' + urlencode({'q': 'Hello, 世界', 'tl': 'ja'})
play_url(url, '192.168.10.101')
Connect wifi and play
import network
import time
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("aterm-SSID-g", "YOUR_PASSWORD")
while not wlan.isconnected() and wlan.status() >= 0:
print("Waiting to connect:")
time.sleep(1)
from pichromecast import play_url
play_url('https://nyanpass.com/nyanpass.mp3', '192.168.10.101')
Lookup host IP
#pip install pychromecast
import pychromecast
services, browser = pychromecast.discovery.discover_chromecasts()
pychromecast.discovery.stop_discovery(browser)
print(services)
[CastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-3b0a32dc5803130351919f8a286e406f._googlecast._tcp.local.')}, uuid=UUID('3b0a32dc-5803-1303-5191-9f8a286e406f'), model_name='Google Home Mini', friendly_name='書斎', host='192.168.10.101', port=8009, cast_type='audio', manufacturer='Google Inc.')]
or use MicroPython MDNS
Demo
Metadata
Release files for pichromecast 0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pichromecast-0.6.tar.gz | 4.1 kB | Without provenance | Details for pichromecast-0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pichromecast-0.6-py3-none-any.whl | Python 3 | none | any | Details for pichromecast-0.6-py3-none-any.whl |
Total release size: 8.5 kB
Release files / pichromecast-0.6.tar.gz
| Download URL | pichromecast-0.6.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22684e1a3ecefde6bcdfdca1b9c2edafb2ea146b5c21f3447bc074f58b523682
|
|
BLAKE2b-256 checksum How to use checksums |
ffeba29424686d83920104d27adde0e60d2dbc0959bba013b74f83664f9ba0a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / pichromecast-0.6-py3-none-any.whl
| Download URL | pichromecast-0.6-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6eb8938affd2c796a07d800bdad16620fe2dc4a95678aae13d08bd088b1c42b5
|
|
BLAKE2b-256 checksum How to use checksums |
3e2bcbfb017dff0ca20d2326b07271b1121d00580a462cf1ce324a83eb729246
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for pichromecast 0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.