pychromecast - how to get started?
i want to be able to interact with google chromecast devices in my home. python has a library called pychromecast. it seems kind of straight forward for a beginner, but i can't get it to show me what chromecasts are on my network. if I use: import pychromecast import zeroconf import time import logging # Enable debug logging logging.basicConfig(level=logging.DEBUG) def discover_chromecasts(): castDevice = pychromecast.Chromecast('192.168.86.222') print(dir(castDevice)) if __name__ == "__main__": discover_chromecasts() i get the output: Error connecting to Chromecast: 'str' object has no attribute 'cast_type' i have played around got the debugging code to display feedback that it can actually find devices on my network, but I don't know, and can't find any information on, how to access the info it finds. A I understand the code (python is a language I don't really know, so I'm just reading it as pseudocode) the castDevice object/variable *should* contain something as long as I point it to a valid IP address of a chromecast device, but it always tells me it's invalid. How can I inspect what the castDevice object is? edit: so i tried using the interactive python shell instead and input the lines one by one like this: >>> import pychromecast >>> import time >>> import zeroconf >>> zconf = zeroconf.Zeroconf() >>> browser = pychromecast.CastBrowser(pychromecast.SimpleCastListener(lambda uuid, service: print(browser.devices[uuid].friendly_name)), zconf) >>> browser.start_discovery() >>> Patio Speaker SHIELD Patio TV browser.stop_discovery() >>> and indeed! it finds the devices on my network and shows the names of the devices! why does it work in the python shell, but not in a script?