X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=smart_home%2Fchromecasts.py;h=408ccf0e12ff3b1702ef7cd4b63d42c357fac7db;hb=532df2c5b57c7517dfb3dddd8c1358fbadf8baf3;hp=bd2a80c54c2af85c191cf5d5272df6bcc7d89cf1;hpb=6ba90a1f30f1c0cf4df12fcd0c62181f29bc3668;p=python_utils.git diff --git a/smart_home/chromecasts.py b/smart_home/chromecasts.py index bd2a80c..408ccf0 100644 --- a/smart_home/chromecasts.py +++ b/smart_home/chromecasts.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +# © Copyright 2021-2022, Scott Gasch + """Utilities for dealing with the webcams.""" import atexit @@ -17,6 +19,8 @@ logger = logging.getLogger(__name__) class BaseChromecast(dev.Device): + """A base class to represent a Google Chromecase device.""" + ccasts: List[Any] = [] refresh_ts = None browser = None @@ -38,20 +42,18 @@ class BaseChromecast(dev.Device): BaseChromecast.ccasts, BaseChromecast.browser, ) = pychromecast.get_chromecasts(timeout=15.0) - assert BaseChromecast.browser + assert BaseChromecast.browser is not None atexit.register(BaseChromecast.browser.stop_discovery) BaseChromecast.refresh_ts = now self.cast = None for cc in BaseChromecast.ccasts: if cc.cast_info.host == ip and cc.cast_info.cast_type != 'group': - logger.debug(f'Found chromecast at {ip}: {cc}') + logger.debug('Found chromecast at %s: %s', ip, cc) self.cast = cc self.cast.wait(timeout=1.0) if self.cast is None: - raise Exception( - f'Can\'t find ccast device at {ip}, is that really a ccast device?' - ) + raise Exception(f'Can\'t find ccast device at {ip}, is that really a ccast device?') def is_idle(self): return self.cast.is_idle