Well,
I fond a way to make it work again !
I deleted everyting that was in the “pycache” sub-folder of these folder :
- gmusicapi
- gmusicapi-10.1.2-py3.6.egg-info
Deleting theses folder in their entirety also seam to work
Well,
I fond a way to make it work again !
I deleted everyting that was in the “pycache” sub-folder of these folder :
Deleting theses folder in their entirety also seam to work
I dont get the first step… - How do i interact with this thing?
https://hastebin.com/irigoquwow.sql
my "code should look like this:
from gmusicapi import Mobileclient
api = Mobileclient()
logged_in = api.login('[email protected]', 'my-password', Mobileclient.FROM_MAC_ADDRESS)
# logged_in is True if login was successful
aha… WHERE?
I dont get it at all
when i got the package active the frontend even wont boot up… - i can get it working when i get rid of the point @ gmusicyaml
I’m having difficulty passing the values of my RFID cards to Google Play Music. There is more detail below but the first, recurring error message I see in the Home Assistant log reads that:
[gmusicapi.protocol.shared] could not locate client caller in stack
…and I don’t understand how to fix that.
I saw from earlier comments that @davemc and @bradc87 had similar problems - but I didn’t see a solution to them. If anyone has any ideas or could point me towards what I’m doing wrong, please let me know. It seems like things are very close to working but I just don’t see what the problem is atm.
This is the basic error log I see in the gmusicapi log file:
!-- begin debug log --!
version: 10.1.2
logging to: /home/homeassistant/.cache/gmusicapi/log/gmusicapi.log
2018-05-07 11:52:23,887 - gmusicapi.GMusic1 (shared:74) [INFO]: initialized
2018-05-07 11:52:23,888 - gmusicapi.GMusic1 (shared:98) [INFO]: logged out
I see something similar, in more detail, after starting the Home Assistant and following its message log - the message about not locating the client caller is on the sixth line:
2018-05-07 11:52:23 INFO (Thread-2) [gmusicapi.GMusic1] !-- begin debug log --!
2018-05-07 11:52:23 INFO (Thread-2) [gmusicapi.GMusic1] version: 10.1.2
2018-05-07 11:52:23 INFO (Thread-2) [gmusicapi.GMusic1] logging to: /home/homeassistant/.cache/gmusicapi/log/gmusicapi.log
2018-05-07 11:52:23 INFO (Thread-2) [gmusicapi.GMusic1] initialized
2018-05-07 11:52:23 INFO (Thread-2) [gmusicapi.GMusic1] logged out
2018-05-07 11:52:24 INFO (Thread-2) [gmusicapi.protocol.shared] could not locate client caller in stack:
File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 66, in _worker
work_item.run()
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/switch/gmusic.py", line 36, in setup_platform
add_devices([GmusicComponent(hass, config)])
File "/home/homeassistant/.homeassistant/custom_components/switch/gmusic.py", line 76, in __init__
logged_in = self._api.login(config.get('user'), config.get('password'), config.get('device_id'), authtoken)
File "/home/homeassistant/.homeassistant/custom_components/switch/gmusic.py", line 54, in login
self.get_registered_devices()
File "/srv/homeassistant/lib/python3.5/site-packages/gmusicapi/clients/mobileclient.py", line 785, in get_registered_devices
res = self._make_call(mobileclient.GetDeviceManagementInfo)
File "/srv/homeassistant/lib/python3.5/site-packages/gmusicapi/clients/shared.py", line 84, in _make_call
return protocol.perform(self.session, self.validate, *args, **kwargs)
File "/srv/homeassistant/lib/python3.5/site-packages/gmusicapi/protocol/shared.py", line 199, in perform
log.debug("%s(args=%s, kwargs=%s)",
File "/srv/homeassistant/lib/python3.5/site-packages/gmusicapi/utils/utils.py", line 107, in __getattr__
stack = traceback.extract_stack()
2018-05-07 11:52:24 INFO (Thread-2) [gmusicapi.protocol.shared] could not locate client caller in stack:
File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 66, in _worker
work_item.run()
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/switch/gmusic.py", line 36, in setup_platform
add_devices([GmusicComponent(hass, config)])
File "/home/homeassistant/.homeassistant/custom_components/switch/gmusic.py", line 76, in __init__
logged_in = self._api.login(config.get('user'), config.get('password'), config.get('device_id'), authtoken)
File "/home/homeassistant/.homeassistant/custom_components/switch/gmusic.py", line 54, in login
self.get_registered_devices()
File "/srv/homeassistant/lib/python3.5/site-packages/gmusicapi/clients/mobileclient.py", line 785, in get_registered_devices
res = self._make_call(mobileclient.GetDeviceManagementInfo)
File "/srv/homeassistant/lib/python3.5/site-packages/gmusicapi/clients/shared.py", line 84, in _make_call
return protocol.perform(self.session, self.validate, *args, **kwargs)
File "/srv/homeassistant/lib/python3.5/site-packages/gmusicapi/protocol/shared.py", line 243, in perform
log.debug(cls.filter_response(parsed_response))
File "/srv/homeassistant/lib/python3.5/site-packages/gmusicapi/utils/utils.py", line 107, in __getattr__
stack = traceback.extract_stack()
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state switch.google_music=off; friendly_name=Google music, icon=mdi:music-note @ 2018-05-07T12:52:24.875636+01:00>, entity_id=switch.google_music>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=<state group.google_music=unknown; friendly_name=Google Music, order=0, entity_id=('input_select.music', 'input_select.media_player', 'switch.google_music') @ 2018-05-07T12:52:20.379026+01:00>, new_state=<state group.google_music=off; friendly_name=Google Music, order=0, entity_id=('input_select.music', 'input_select.media_player', 'switch.google_music') @ 2018-05-07T12:52:24.886291+01:00>, entity_id=group.google_music>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=group, service=set, service_data=name=all switches, object_id=all_switches, entities=['switch.google_music'], visible=False, service_call_id=1976017008-3>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state group.all_switches=off; friendly_name=all switches, order=3, auto=True, hidden=True, entity_id=('switch.google_music',) @ 2018-05-07T12:52:24.891609+01:00>, entity_id=group.all_switches>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=switch, service=turn_off>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=switch, service=turn_on>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=switch, service=toggle>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.setup] Setup of domain switch took 4.5 seconds.
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=switch>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1976017008-3>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in 9.00s
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Starting Home Assistant core loop
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Starting Home Assistant
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event homeassistant_start[L]>
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.components.automation] Initialized trigger Playlist Value Changes
2018-05-07 11:52:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=<state automation.playlist_value_changes=off; last_triggered=None, friendly_name=Playlist Value Changes, id=1521492851100 @ 2018-05-07T12:52:20.488017+01:00>, new_state=<state automation.playlist_value_changes=on; last_triggered=None, friendly_name=Playlist Value Changes, id=1521492851100 @ 2018-05-07T12:52:24.916257+01:00>, entity_id=automation.playlist_value_changes>
2018-05-07 11:52:24 INFO (Thread-7) [gmusicapi.protocol.shared] could not locate client caller in stack:
File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
....
If I let Home Assistant just run on its own, I get this ongoing, repeated message from the log (192.168.1.7 is the address of the laptop I’m using to ssh in to my Raspberry Pi):
2018-05-07 12:14:48 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:14:53 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:14:58 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:04 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:09 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:14 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:19 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:25 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:30 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:35 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:40 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:45 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:51 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:15:56 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:16:01 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:16:06 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:16:12 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
2018-05-07 12:16:17 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
After I pass the value of a Google Play Music playlist via RFID, these are the messages in the log:
2018-05-07 12:18:25 INFO (MainThread) [homeassistant.components.http.view] Serving /api/services/input_text/set_value to 192.168.1.10 (auth: True)
2018-05-07 12:18:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=input_text, service=set_value, service_data=value=TheGetaway, entity_id=input_text.playlist, service_call_id=1976017008-5>
2018-05-07 12:18:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1976017008-5>
2018-05-07 12:18:28 INFO (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.7 (auth: False)
…but beyond those log messages nothing really seems to happen as a result - my Google Play Music playlist, TheGetaway in the example above, appears in the Input Text area of the Home Assistant interface but it doesn’t start playing through one of my Google Home devices.
Again, if anyone has any ideas please let me know.
Thank you
Hi @hovee -
Thanks for your help. Can you let me know what the value is of id in your automations.yaml file?
When running pip install gmusic in hassio, I see this in the log:
ERROR (MainThread) [homeassistant.components.shell_command] Error running command:
pip install gmusic
, return code: 127
When running pip3 install gmusic in hassio, I see this in the log:
ERROR (MainThread) [homeassistant.components.shell_command] Error running command:
pip3 install gmusic
, return code: 1
I’m running 0.68.1 on a Raspberry Pi 3 Model B
Any suggestions?
Edit: Fixed. Had to use install_gmusic: pip3 install gmusicapi
Is anyone getting the following error? Just started today and I have tried a restart already, no changes or updates otherwise
Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?net=mob&pt=e&songid=12699f3d-942f-3a2c-a1ce-d70359a73878&sig=ESoY1FgsqiLth8oq6Ntl_yB_ea8&opt=hi&tier=fr&dv=0&slt=1527613970745&hl=en_US
Edit: Solved by changing the device_id to another authorized device.
Trying to set this up using a chromecast audio and hass.io and I’m receiving the following error when I try to start it
ERROR (SyncWorker_10) [custom_components.switch.gmusic] media_player.chromecast is not a valid media player.
media_player.chromecast should be valid. I can see the entity in my States panel.
Edit: Had to use “chromecast” and NOT “media_player.chromecast”
Try with chromecast
and NOT media_player.chromecast
Thanks, that worked.
Does the device_id have to be an android ID? I have tried with both my ios ID and my desktop ID, but I keep getting the error:
Failed to get track (GetStreamUrl: 403 Client Error: Forbidden for url:
Edit: Looks like it does require an android ID. I had to download an emulator and stream google music on it for that to register
I am using hassio, and when I try
pip3 install gmusicapi
It downloads and installs until freezing and I see
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-opm7ny4k/pycryptodomex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-nbj9quo8/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-opm7ny4k/pycryptodomex/
is there a dependency or something that I need to install first?
(I am doing this through a ssh terminal screen, as I put in the
install_gmusic: pip3 install gmusicapi
in the configuration.yaml but I assume I was getting a similar error as HA wouldn’t startup because it was hung on this step.)
I am also using hassio. Installing gmusicapi seemed to go fine.
After I add the switch to my config and reboot I get the following error:
2018-06-03 20:56:15 INFO (MainThread) [homeassistant.components.switch] Setting up switch.gmusic
2018-06-03 20:56:20 INFO (SyncWorker_15) [gmusicapi.GMusic1] !-- begin debug log --!
2018-06-03 20:56:20 INFO (SyncWorker_15) [gmusicapi.GMusic1] version: 10.1.2
2018-06-03 20:56:20 INFO (SyncWorker_15) [gmusicapi.GMusic1] logging to: /root/.cache/gmusicapi/log/gmusicapi.log
2018-06-03 20:56:20 INFO (SyncWorker_15) [gmusicapi.GMusic1] initialized
2018-06-03 20:56:20 INFO (SyncWorker_15) [gmusicapi.GMusic1] logged out
2018-06-03 20:56:22 INFO (SyncWorker_15) [gmusicapi.GMusic1] failed to authenticate
HA then fails to start.
I’m guessing the issue has to do with the device ID but I cannot seem to be able to get a valid one. I also cannot seem to find the log file indicated above.
Any help would be appreciated as this looks like a great component.
Edit: Solved this. I read the gmusicapi documentation again (http://unofficial-google-music-api.readthedocs.io/en/latest/reference/mobileclient.html) as indicated in the gmusic.yaml file. The problem was that I overlooked the 2-factor Authentication (I believe a comment above also mentioned this). Once I created an app specific password (https://myaccount.google.com/apppasswords) the authentication worked. The Device ID I had didn’t work but a valid one was given in the logs to use. Hopefully this helps someone else set this up.
@claytonjn Did you ever find a way to include the auto-generated playlists? I Changed gmusic.py slightly per the gmusicapi docs to pull all the playlists, including the public ones in your library. Unfortunately ‘Thumbs Up’ did not show up.
I changed this:
self._playlists = self._api.get_all_user_playlist_contents()
To this:
self._playlists = self._api.get_all_playlists()
Edit:
To get this to work with the .get_all_playlists() method I needed to use @JKW 's code for def _next_track and def _play which creates a radio from the playlists. There is no ‘tracks’ key in the dictionary of get_all-playlists() which caused it to break using the original code.
Thanks @Danielhiversen and @JKW for the components!
I did not, what I ended up doing was building an Android VM that allows me to send commands to Google Assistant. For my purposes this works perfectly.
Follow steps listed below for Gmusic to work with Hassio
I am just putting all the steps together for ease of use.
Add the component from link to your custom_component/gmusic/
Note: after update 0.88 rename gmusic.py to switch.py and copy to above link Thanks to @Danielhiversen
home-assistant_config/custom_components/switch/gmusic.py at master · Danielhiversen/home-assistant_config · GitHub
Add folder named packages in config folder.
Then include packages folder in configuration.yaml as below.
homeassistant:
packages: !include_dir_named packages
Download gmusic.yaml to config/packages from the link below Thanks to @cogneato
gmusic.yaml · GitHub
Update gmusic.yaml with entity_ids of your media player
media_player:
name: Speakers
options: # entity_ids of your media players
- “every_speaker”
- “first_floor_speakers”
- “kitchen_home”
- “chromcast_onkyo”
- “basement_speaker”
icon: mdi:speaker-wireless
gmusic_user: your email here
gpassword: your password here
gmusic_device_id: 123456789abcdefg
thanks for the tutorial. I just tried it and found that I had to do a “restart” under “server management” as reload core only does the customisation.
@claytonjn yeah I saw your other post on the Google Assistant thread. I might have to try that. Thanks!
With hassio 0.71.0 I simpy do not get an error message with the correct gmusic_device_id. Instead, I always get the following error when trying to setup google play music. Any idea what i could try?
Error handling request
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 385, in start
resp = await self._request_handler(request)
File "/usr/lib/python3.6/site-packages/aiohttp/web_app.py", line 338, in _handle
resp = await handler(request)
File "/usr/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 88, in impl
return await handler(request)
File "/usr/lib/python3.6/site-packages/homeassistant/components/http/static.py", line 68, in staticresource_middleware
return await handler(request)
File "/usr/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 27, in real_ip_middleware
return await handler(request)
File "/usr/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 68, in ban_middleware
return await handler(request)
File "/usr/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 54, in auth_middleware
return await handler(request)
File "/usr/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 98, in handle
result = await result
File "/usr/lib/python3.6/site-packages/homeassistant/components/config/core.py", line 24, in post
errors = yield from async_check_ha_config_file(request.app['hass'])
File "/usr/lib/python3.6/site-packages/homeassistant/config.py", line 714, in async_check_ha_config_file
check_ha_config_file, hass)
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 372, in check_ha_config_file
platform = loader.get_platform(hass, domain, p_name)
File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 58, in get_platform
return get_component(hass, PLATFORM_FORMAT.format(domain, platform))
File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 86, in get_component
module = importlib.import_module(path)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 674, in exec_module
File "<frozen importlib._bootstrap_external>", line 781, in get_code
File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/config/custom_components/switch/gmusic.py", line 7
<!DOCTYPE html>
^
SyntaxError: invalid syntax
Check comment 121 from spartan.
on subsequent restarts it should function, just make sure to give that command enough time to run before restarting.
Hm, still no luck for me. Seems like my Hassio cannot install the gmusicapi:
Not initializing switch.gmusic because could not install requirement gmusicapi==10.1.2
Unable to install package gmusicapi==10.1.2: Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-sgys7uxn/lxml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-qn0g6r1g-record/install-record.txt --single-version-externally-managed --prefix --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-sgys7uxn/lxml/
lets try a different approach of getting the device id.
I wont be able to help you with the installation, as I only know one method of adding below to the configuration or from any yaml file to make it work.
shell_command:
install_gmusic: pip3 install gmusicapi
automation:
- alias: homeassistant_start
trigger:
- platform: homeassistant
event: start
action:
- service: shell_command.install_gmusic