8000 0.59 breaks pychromecast · Issue #10926 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

0.59 breaks pychromecast #10926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
edif30 opened this issue Dec 3, 2017 · 30 comments · Fixed by #10989
Closed

0.59 breaks pychromecast #10926

edif30 opened this issue Dec 3, 2017 · 30 comments · Fixed by #10989

Comments

@edif30
Copy link
Contributor
edif30 commented Dec 3, 2017

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
0.59

Python release (python3 --version):
3.6

Component/platform:
pychromecast

Description of problem:
Ever since upgrade to 0.59, I get multiple tracebacks for pychromecast. Downgrading to 0.58.1 resolves the issue. Easily reproduced by running any automation that has a cast action.

Expected:
No errors

Problem-relevant configuration.yaml entries and steps to reproduce:
not sure if this is relevant - #10728 as that is the only change to the platform I can see in the repo.

Traceback (if applicable):

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 182, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/core.py", line 1031, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 408, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/components/media_player/cast.py", line 315, in play_media
    self.cast.media_controller.play_media(media_id, media_type)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/controllers/media.py", line 465, in play_media
    callback_function=app_launched_callback)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/socket_client.py", line 803, in launch_app
    self.update_status(lambda response:
  File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/socket_client.py", line 794, in update_status
    callback_function=callback_function_param)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/controllers/__init__.py", line 84, in send_message
    self.namespace, data, inc_session_id, callback_function)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/socket_client.py", line 603, in send_platform_message
    inc_session_id, callback_function_param)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/socket_client.py", line 597, in send_message
    raise NotConnected("Chromecast is connecting...")
pychromecast.error.NotConnected: Chromecast is connecting...

Additional info:

If this is due to the firmware on cast devices and the API, I am not sure what needs to be done in HA if anything as this seems to be a breaking change with the pychromecast version bump. I only have this configuration in HA.

  - platform: cast
    host: !secret cast_host1 -- Just an IP address

I also see the latest version via the setup says 1.0.2 but this link says 1.0.1 is

https://github.com/balloob/pychromecast/releases/tag/1.0.1

Maybe I'm missing something.

@point-4ward
Copy link
Contributor

Yeah, I've lost streaming too since upgrade.

@edif30
Copy link
Contributor Author
edif30 commented Dec 3, 2017

@mf-social are you casting to a group within HA (not the group created in home app) or just a single device?

@point-4ward
Copy link
Contributor

I haven't grouped any of the devices in HA, just in Google Home app.

My configuration is simply - platform: cast

I have 3 devices (living room, kitchen and bedroom)

I have 2 groups (everywhere - all 3, and downstairs - living room and kitchen)

I cannot cast to anything atm. They wake up when the play_media call goes out, but nothing plays and I get a shed load of errors in the logs. Local files and remote streams have both been tested, same result.

Hope this is enough information, but if you need anything else let me know.

@edif30
Copy link
Contributor Author
edif30 commented Dec 3, 2017

I just reported it, I'm not a python guy lol. Hopefully someone with some knowledge on the subject can help us. Thanks for confirming. I was hoping it wasn't just because I have devices grouped in HA. I stopped using google home groups because the device ID would change randomly and I'd get occasional errors

@ferdydek
Copy link
ferdydek commented Dec 4, 2017

+1 for me. Also use Groups in GH.

@chocomega
Copy link
Contributor

Same here

Home Assistant release (hass --version):
0.59.0

Python release (python3 --version):
3.5.2

Description of problem:
Turning on media players such as chromecast audio or google home mini fails.
The media player state is still off.

Expected:
Turn on without errors

Problem-relevant configuration.yaml entries and steps to reproduce:
Auto discovery configuration

  1. Turn on chromecast audio or google home mini media player

Additional info:
When the google home mini media player is turned on, I do hear the chime sound as if the Default Media Receiver was started (and the Google home app also shows Default Media Receiver) but the state in HA is still off. Chromecast video seems to work fine though.

No issues when downgrading to 0.58.1

Firmware version:
Chromecast video: 1.28.100555
Chromecast audio: 1.28.100555
Google home mini: 1.28.100429

@mmotley999
Copy link

I'm also having issues with TTS to a Google Home unit, with a simple automation that triggers TTS when the garage door changes state (e.g. "Garage Door Is Open" when it opens). Worked under 0.58.1 (and prior) and Logbook shows that the automation is triggering.

Only one Chromecast device, the Google Home.

Getting this traceback:

Dec  3 19:23:20 hass1 hass[591]: #033[32m2017-12-03 19:23:20 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=play_media, service_data=media_content_id=http://10.10.20.46:8123/api/tts_proxy/dc724af18fbdd4e59189f5fe768a5f8311527050_en_-_google.mp3, media_content_type=music, entity_id=['media_player.family_room_home'], service_call_id=1967042864-954>#033[0m
Dec  3 19:23:20 hass1 hass[591]: #033[31m2017-12-03 19:23:20 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved#033[0m
Dec  3 19:23:20 hass1 hass[591]: Traceback (most recent call last):
Dec  3 19:23:20 hass1 hass[591]:   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 182, in _step
Dec  3 19:23:20 hass1 hass[591]:     result = coro.throw(exc)
Dec  3 19:23:20 hass1 hass[591]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/core.py", line 1031, in _event_to_service_call
Dec  3 19:23:20 hass1 hass[591]:     yield from service_handler.func(service_call)
Dec  3 19:23:20 hass1 hass[591]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 408, in async_service_handler
Dec  3 19:23:20 hass1 hass[591]:     yield from getattr(player, method['method'])(**params)
Dec  3 19:23:20 hass1 hass[591]:   File "/usr/local/lib/python3.6/asyncio/futures.py", line 332, in __iter__
Dec  3 19:23:20 hass1 hass[591]:     yield self  # This tells Task to wait for completion.
Dec  3 19:23:20 hass1 hass[591]:   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
Dec  3 19:23:20 hass1 hass[591]:     future.result()
Dec  3 19:23:20 hass1 hass[591]:   File "/usr/local/lib/python3.6/asyncio/futures.py", line 245, in result
Dec  3 19:23:20 hass1 hass[591]:     raise self._exception
Dec  3 19:23:20 hass1 hass[591]:   File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
Dec  3 19:23:20 hass1 hass[591]:     result = self.fn(*self.args, **self.kwargs)
Dec  3 19:23:20 hass1 hass[591]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/components/media_player/cast.py", line 315, in play_media
Dec  3 19:23:20 hass1 hass[591]:     self.cast.media_controller.play_media(media_id, media_type)
Dec  3 19:23:20 hass1 hass[591]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/controllers/media.py", line 465, in play_media
Dec  3 19:23:20 hass1 hass[591]:     callback_function=app_launched_callback)
Dec  3 19:23:20 hass1 hass[591]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/socket_client.py", line 803, in launch_app
Dec  3 19:23:20 hass1 hass[591]:     self.update_status(lambda response:
Dec  3 19:23:20 hass1 hass[591]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/socket_client.py", line 794, in update_status
Dec  3 19:23:20 hass1 hass[591]:     callback_function=callback_function_param)
Dec  3 19:23:20 hass1 hass[591]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/controllers/__init__.py", line 84, in send_message
Dec  3 19:23:20 hass1 hass[591]:     self.namespace, data, inc_session_id, callback_function)
Dec  3 19:23:20 hass1 hass[591]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/socket_client.py", line 603, in send_platform_message
Dec  3 19:23:20 hass1 hass[591]:     inc_session_id, callback_function_param)
Dec  3 19:23:20 hass1 hass[591]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/pychromecast/socket_client.py", line 597, in send_message
Dec  3 19:23:20 hass1 hass[591]:     raise NotConnected("Chromecast is connecting...")
Dec  3 19:23:20 hass1 hass[591]: pychromecast.error.NotConnected: Chromecast is connecting...#033[0m

@balloob
Copy link
Member
balloob commented Dec 4, 2017

CC @OttoWinter

@craigjmidwinter
Copy link
Contributor

I seem to be experiencing the same issue on 0.59.1

@OttoWinter
Copy link
Member

Huh... That's really weird. Even more so because I myself am not experiencing any of these errors. Anyway, I'm really sorry for breaking some cast devices.

Now to the error: I think it's really weird these errors are appearing when attempting play some audio and in the SocketClient class; I mean the code I changed was only used during the initialization phase and so it would be much easier to understand if the initialization of some devices failed and they wouldn't show up, but that doesn't seem to be the case here.

My first guess would be that some parameter handed to SocketClient is incorrect - but the only one is cast_type which probably wouldn't cause such an error.

I really currently have no idea what might be causing this. I'm currently not at home but I'll look into it more in a few hours.

@OttoWinter
Copy link
Member

Just noticed this commit which corresponds quite well with the error (self.connecting staying set to True -> the mentioned error in the log because self.connecting is True). I don't really know why I bumped the version to 1.0.2 in my Hass PR #10728 (probably to include home-assistant-libs/pychromecast#198 - I don't know much about how pip works), but maybe somebody could try without that commit and share their results. Thx!

@balloob
Copy link
Member
balloob commented Dec 5, 2017

Ah, sorry for CCing you @OttoWinter but thanks for trying to figure it out anyway. Would be great if someone that experiences the error can report back if that fixes it.

@balloob
Copy link
Member
balloob commented Dec 5, 2017

I actually don't think that the referenced commit is part of the release that we included. If someone can try with reverting these changes, that might be the culprit: https://github.com/balloob/pychromecast/pull/184/files#diff-9829f5e02f299d2bfb52a4d320201b8eR820

@ferdydek
Copy link
ferdydek commented Dec 5, 2017

@OttoWinter @balloob
Tested this yesterday with @edif30, forcing 0.8.2 does not change the behavior.

Issue is present on all devices except Ultra. Ultra also is the only one that still shows the volume control.
Issue is present regardless if GH group is defined or not (one of my CAudio being part of the group is powered off, I initially thought this could be the issue as all affected devices are part of the group and Ultra being the only unaffected is not as its not compatible with GH group).

My setup (diff ver from @chocomega) @OttoWinter can you compare with yours please?
Audios: 1.29.104827 (beta)
Ultra: 1.28.100555
Home: 1.28.99956

Side note: I did get, I believe always on 1st attempt of tts the following error:

2017-12-04 00:00:15 ERROR (MainThread) [homeassistant.components.tts.google] Error 404 on load url http://translate.google.com/translate_tts?total=1&client=tw-ob&q=&textlen=0&tk=688168.846120&idx=0&tl=en&ie=UTF-8
2017-12-04 00:00:15 ERROR (MainThread) [homeassistant.components.tts] Error on init tts: No TTS from google for ''

@ferdydek
Copy link
ferdydek 8000 commented Dec 5, 2017

Just noticed another issue which makes me think this may not be linked with the cast libraries at all: I have webostv setup since ever, and I have the same lack of control (no volume, no current selected app, does not respond to anything except power on [power on state is not detected, only actually powers on the device]).
No matter what this is static:
image

Can you guys test other media_player devices in installations where cast is affected?

@OttoWinter
Copy link
Member

So I just figured out how to recreate this issue using my Google Home Mini (version 1.28.100429).

For me, after restarting Home Assistant the Home Mini works and I can play tts without a problem - though if I stop the "Default Media Playback" using the power on/off button in hass, I experience the same issue as @chocomega : Only the playback-begin chime is played but nothing else + the pychromecast.error.NotConnected: Chromecast is connecting... exception.

@OttoWinter
Copy link
Member

I'm now starting to think that the chime issue and SocketClient error are unrelated because I now am able to replicate the chime issue with a small script - but I'm not getting any pychromecast.error.NotConnected errors. Maybe somebody who knows more about pychromecast can check out what might be going wrong here. With my setup, the first time play_media is called everything works just fine and type': 'LOAD' is sent but the second time it is called the library seems to be waiting indefinitely for 'type': 'GET_STATUS' to succeed.

import pychromecast
import time
import logging


logging.basicConfig(level=logging.DEBUG)
c = pychromecast.get_chromecasts()[0]
mc = c.media_controller

URL = 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3'
print("Casting media...")
mc.play_media(URL, 'music')
time.sleep(10)

print("Stopping app...")
c.quit_app()
time.sleep(5)

print("Casting media...")
mc.play_media(URL, 'music')
time.sleep(10)

(That song is just a random mp3 I snagged from the internet and does not remotely reflect my music interest 😂 )

@bachoo786
Copy link

Same here cannot play mp3 files keep getting: pychromecast.error.NotConnected: Chromecast is connecting...

@OttoWinter
Copy link
Member
OttoWinter commented Dec 5, 2017

@balloob Ok, I just tried removing your suspected culprit home-assistant-libs/pychromecast#184 and the chime issue appears to be gone now! I guess this is because _block_till_launched only calls the callback passed to _send_launch_message if the library is in blocking mode, which it is not in home assistant.

I'm not quite sure whether that will also fix the NotConnected error, but I will try that in a moment.

@ryanm101
Copy link
Contributor
ryanm101 commented Dec 5, 2017

Home Assistant release (hass --version):*
0.59.1

Component/platform:
hass.io -> media_player

Description of problem:
Cannot "Turn on" devices or play TTS through them (also applies to sending music)

Expected:
Be able to "turn on" and use TTS

$> pip install pychomecast==0.8.2
$> python
>> import pychromecast
>> x = pychromecast.get_chromecasts()
>> c=x[0]
>> c.status
CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.10000000149011612, volume_muted=False, app_id=None, display_name=None, namespaces=[], session_id=None, transport_id=None, status_text='')

>> c.play_media('https://home-assistant.io/images/cast/splash.png', pychromecast.STREAM_TYPE_BUFFERED)
>> c.status
CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.10000000149011612, volume_muted=False, app_id='CC1AD845', display_name='Default Media Receiver', namespaces=['urn:x-cast:com.google.cast.debugoverlay', 'urn:x-cast:com.google.cast.broadcast', 'urn:x-cast:com.google.cast.media'], session_id='a7e3986d-171e-46a5-9188-058681d4f304', transport_id='a7e3986d-171e-46a5-9188-058681d4f304', status_text='Now Casting')

>> c.quit_app()
>> c.status
CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.10000000149011612, volume_muted=False, app_id=None, display_name=None, namespaces=[], session_id=None, transport_id=None, status_text='')

Updating to new version

$> pip install pychomecast==1.0.2
$> python
>> import pychromecast
>> x = pychromecast.get_chromecasts()
>> c=x[0]
>> c.status
CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.10000000149011612, volume_muted=False, app_id=None, display_name=None, namespaces=[], session_id=None, transport_id=None, status_text='')

>>> c.play_media('https://home-assistant.io/images/cast/splash.png', pychromecast.STREAM_TYPE_BUFFERED)
>>> c.status
CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.10000000149011612, volume_muted=False, app_id=None, display_name=None, namespaces=[], session_id=None, transport_id=None, status_text='')

Running >>> c.play_media('https://home-assistant.io/images/cast/splash.png', pychromecast.STREAM_TYPE_BUFFERED) ~3 times results in

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ryanm/workspace/home-assistant/vplex/lib64/python3.6/site-packages/pychromecast/controllers/media.py", line 465, in play_media
    callback_function=app_launched_callback)
  File "/home/ryanm/workspace/home-assistant/vplex/lib64/python3.6/site-packages/pychromecast/socket_client.py", line 803, in launch_app
    self.update_status(lambda response:
  File "/home/ryanm/workspace/home-assistant/vplex/lib64/python3.6/site-packages/pychromecast/socket_client.py", line 794, in update_status
    callback_function=callback_function_param)
  File "/home/ryanm/workspace/home-assistant/vplex/lib64/python3.6/site-packages/pychromecast/controllers/__init__.py", line 84, in send_message
    self.namespace, data, inc_session_id, callback_function)
  File "/home/ryanm/workspace/home-assistant/vplex/lib64/python3.6/site-packages/pychromecast/socket_client.py", line 603, in send_platform_message
    inc_session_id, callback_function_param)
  File "/home/ryanm/workspace/home-assistant/vplex/lib64/python3.6/site-packages/pychromecast/socket_client.py", line 597, in send_message
    raise NotConnected("Chromecast is connecting...")
pychromecast.error.NotConnected: Chromecast is connecting...

@ryanm101
Copy link
Contributor
ryanm101 commented Dec 5, 2017

Reverting Hass.io to 0.58.1 resolves the issue

@neuman1812
Copy link

Currently on .58.1 I have not upgraded to 59. I am unable to get the google mini to play. I do get the google chime startup, but no audio

@balloob
Copy link
Member
balloob commented Dec 6, 2017

I'm reverting to the old pychromecast in 0.59.2. Will give people time to figure out what is wrong with the new pychromecast version.

@edif30
Copy link
Contributor Author
edif30 commented Dec 6, 2017

Thanks all! If you need me to test anything, please let me know!

@jjanderson
Copy link

I have now rolled back Home Assistant (Running in Docker on Synology) to 0.58.1, however my chromecast devices are still not being discovered. Any ideas?

@OttoWinter
Copy link
Member

@jjanderson Chromecast discovery doesn't currently work inside Docker containers (zeroconf basically only listens on one interface for discovery messages).

@jjanderson
Copy link
jjanderson commented Dec 13, 2017

@OttoWinter This was working until around 58 cant remember which version it stopped wortking on, but all my Chromecast devices used to be discovered (LG Musicflows x4, Android with caster app) even the groups were discovered correctly... and that was without stipulating host or anything else, pure discovery... in fact it used to annoy me that it would actually discover things I did not want to have in the UI so actually made these hidden in my customize.yaml, so I definately know that discovery did used to work in docker

@danpowell88
Copy link

I have discovery currently working in docker, 0.59.2, network is set to host mode though.

The other issue I have is that the minis I have don't seem to play the tts sound on the first go, if i sent it I heard the notification tone and then nothing, then send it again and it plays, kind of like it needs to be woken up.

@OttoWinter
Copy link
Member

@jjanderson Sorry, I didn't think of the net: host mode - I'm just so used to manually having to add my Chromecast devices. Well anyway, if it stopped working around the 0.58 release I believe it is not related to this particular issue, but I would take a look at home-assistant-libs/pychromecast#197. Could you try manually downloading the latest version of pychromecast (pip install pychromecast) and running the following code:

import pychromecast

pychromecast.get_chromecasts()

@OttoWinter
Copy link
Member

@danpowell That issue should be fixed via home-assistant-libs/pychromecast#202, could you try with the latest pychromecast version?

@home-assistant home-assistant locked and limited conversation to collaborators Mar 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

0