1

I want to make a tts script to my google home i saw a youtube video on it and really wanted to make it but when i executed the code i got this error and i dont know how to fix it AttributeError: 'list' object has no attribute 'device'

here is the code that i used (only the part were i got the error)

CastDevice = pychromecast.get_chromecasts()
cast = next(cc for cc in CastDevice if cc.device.friendly_name == 'Rum')
cast.wait()
media = cast.media_controller
media.play_media(r.url, content_type='audio/mp3')
media.block_until_active()
media.play()
NaWa
  • 11
  • 4
  • Can you show the output of `print(list(CastDevice))`? – enzo Oct 29 '21 at 20:17
  • Your error means that at least one element inside of `CastDevice` is a list. So you can't access the `device` method of a list. – enzo Oct 29 '21 at 20:36
  • We need to see what are the contents of `list(CastDevice)`, but you can try `next(cc for cc in CastDevice if not isinstance(cc, list) and cc.device.friendly_name == 'Rum')` to see if it happens what you want. – enzo Oct 29 '21 at 20:40
  • It didn't fix it but i got a new error `'CastBrowser' object has no attribute 'device'` – NaWa Oct 29 '21 at 20:44

0 Answers0