harperreed / google-home-notifier-python Goto Github PK
View Code? Open in Web Editor NEWA google home notification webservice
A google home notification webservice
Thanks Harper for Obama... and the interface.
The main.py runs ok no errors but I am not getting a sound from the Google Home. Except the first time when lounching app CC1AD845 I can hear the short "ploom".
My log:
ARNING:werkzeug: * Debugger is active!
INFO:werkzeug: * Debugger PIN: 318-290-727
INFO:root:http://eee:5000/static/cache/co-tam-sie-dzieje-pl-false.mp3
http://eee:5000/static/cache/co-tam-sie-dzieje-pl-false.mp3
INFO:pychromecast.controllers:Receiver:Launching app CC1AD845
INFO:werkzeug:192.168.90.2 - - [13/Oct/2017 15:26:09] "GET /say/?text=%22co%20tam%20sie%20dzieje%22&lang=pl HTTP/1.1" 200 -
INFO:root:http://eee:5000/static/cache/co-tam-sie-dzieje-pl-false.mp3
http://eee:5000/static/cache/co-tam-sie-dzieje-pl-false.mp3
INFO:pychromecast.controllers:Not launching app CC1AD845 - already running
INFO:werkzeug:192.168.90.2 - - [13/Oct/2017 15:26:22] "GET /say/?text=%22co%20tam%20sie%20dzieje%22&lang=pl HTTP/1.1" 200 -
Play mp3 behaves the same.
This is not an issue more a question:
Can we just run the notifier webservice over Apache. I already have a full home automation solution that already runs an Apache web server.
Please give us a way to integrate on existing web servers.
Thanks
I ran your notifi.sh shell script and started the docker image. Now how do I access the /say/ or /play/ URLs. When I enter http://localhost/say/?text=Hello or http://127.0.0.1/say/?text=Hello nothing works. Do I need to a have a webserver such as apache running on the machine.
Everything seems to be working for me except the audio file doesn't actually play through my speaker.
Can't figure out what is going wrong.
When try to launch main.py, it causes AttributeError: 'Chromecast' object has no attribute 'cast_info'
Startup fails.
INFO:root:Starting up chromecasts
INFO:pychromecast:Querying device status
INFO:root:Searching for ghm
Traceback (most recent call last):
File "/home/gh-notifier/google-home-notifier-python/main.py", line 19, in <module>
cast = next(cc for cc in chromecasts if cc.cast_info.friendly_name == chromecast_name)
File "/home/gh-notifier/google-home-notifier-python/main.py", line 19, in <genexpr>
cast = next(cc for cc in chromecasts if cc.cast_info.friendly_name == chromecast_name)
AttributeError: 'Chromecast' object has no attribute 'cast_info'
python main.py launches successfully.
I'm using it with Google Home Mini.
$ pip list
Package Version
------------------ ---------
casttube 0.2.1
certifi 2021.5.30
charset-normalizer 2.0.4
click 8.0.1
Flask 2.0.1
gTTS 2.2.3
idna 3.2
ifaddr 0.1.7
itsdangerous 2.0.1
Jinja2 3.0.1
MarkupSafe 2.0.1
pathlib 1.0.1
pip 21.1.3
protobuf 3.17.3
PyChromecast 9.2.0
requests 2.26.0
setuptools 56.0.0
six 1.16.0
unicode-slugify 0.1.3
Unidecode 1.2.0
urllib3 1.26.6
Werkzeug 2.0.1
zeroconf 0.36.0
WARNING: You are using pip version 21.1.3; however, version 22.0.4 is available
With debugging, it seems there is a case that cast_info property can not be accessible.
>>> print(chromecasts)
[Chromecast(None, port=8009, device=DeviceStatus(friendly_name='ghm', model_name='Google Home Mini', manufacturer='Google Inc.', uuid=UUID('...'), cast_type='audio'))]
>>> cast = chromecasts[0]
>>> cast
Chromecast(None, port=8009, device=DeviceStatus(friendly_name='ghm', model_name='Google Home Mini', manufacturer='Google Inc.', uuid=UUID('...'), cast_type='audio'))
cast. doesn't show cast_info.
>>> cast.
cast.app_display_name cast.model_name cast.socket_client
cast.app_id cast.name cast.start(
cast.cast_type cast.new_cast_status( cast.start_app(
cast.connect( cast.play_media( cast.status
cast.device cast.quit_app( cast.status_event
cast.disconnect( cast.register_connection_listener( cast.uri
cast.ignore_cec cast.register_handler( cast.uuid
cast.is_idle cast.register_launch_error_listener( cast.volume_down(
cast.join( cast.register_status_listener( cast.volume_up(
cast.logger cast.set_volume( cast.wait(
cast.media_controller cast.set_volume_muted(
I've used cast.name as a workaround.
$ git diff
diff --git a/main.py b/main.py
index 3fde0a2..2e55441 100644
--- a/main.py
+++ b/main.py
@@ -16,7 +16,7 @@ app = Flask(__name__)
logging.info("Starting up chromecasts")
chromecasts, _ = pychromecast.get_chromecasts()
logging.info("Searching for {}".format(chromecast_name))
-cast = next(cc for cc in chromecasts if cc.cast_info.friendly_name == chromecast_name)
+cast = next(cc for cc in chromecasts if cc.name == chromecast_name)
def play_tts(text, lang='en', slow=False):
tts = gTTS(text=text, lang=lang, slow=slow)
I get the following error after running docker-compose up
:
Attaching to home-notifier
home-notifier | INFO:root:Starting up chromecasts
home-notifier | INFO:root:Searching for None
home-notifier | Traceback (most recent call last):
home-notifier | File "main.py", line 19, in <module>
home-notifier | cast = next(cc for cc in chromecasts if cc.device.friendly_name == chromecast_name)
home-notifier | StopIteration
home-notifier exited with code 1
I changed GRP_NAME in Dockerfile to the device name. I have only one Google Device.
Getting the following error on my Raspberry PI after following instructions on installing, any ideas?
Traceback (most recent call last):
File "main.py", line 3, in
import pychromecast
File "/usr/local/lib/python2.7/dist-packages/pychromecast/init.py", line 15, in
from .discovery import discover_chromecasts, start_discovery, stop_discovery
File "/usr/local/lib/python2.7/dist-packages/pychromecast/discovery.py", line 5, in
from zeroconf import ServiceBrowser, Zeroconf
File "/usr/local/lib/python2.7/dist-packages/zeroconf.py", line 175
def current_time_millis() -> float:
^
SyntaxError: invalid syntax
Hello,
Really good job :-)
But how i can launch the script at boot on raspberry pi, I've tried many time but i've got error:
Traceback (most recent call last):
File "/home/pi/Desktop/google-home-notifier-python/main.py", line 3, in
import pychromecast
ImportError: No module named pychromecast
If i launch the script via the command line it's work like a charme.
Thanks
This app crashes if the google home device is switched off.
How to overcome this..?
I'm using on Windows 10 with Python 3.6.8 and a Google Home Mini. Using your main.py and can connect to my mini but when using play_mp3("doorbell1.mp3") it either plays very fast, like 4 or 5 rings in just a second or not at all, works about 1 time out of 5 to 10 tries. What can I do so it plays at the correct speed and consistently works?
I can't use play("doorbell1.mp3") since I get the errors:
RuntimeError: Working outside of request context.
This typically means that you attempted to use functionality that needed an active HTTP request
Thanks - Gary
say command is not working at all
when i use the "say" command my google home just make a sound and then nothing
Let me know
Hi. How to access Google home IP address remotely when I'm outside of local wifi network?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.