X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=smart_home%2Fcameras.py;h=e8f164b3c0a6f1529347c79400b1036623a87d58;hb=a9bdfd8fc9f84b7b2c09a57cd12ba32259e84d1c;hp=8643611811f69f61a6c46f37f9c6680c0479d441;hpb=52ffdbae73f20b49a1451df2652a8bbc0c4dcac1;p=python_utils.git diff --git a/smart_home/cameras.py b/smart_home/cameras.py index 8643611..e8f164b 100644 --- a/smart_home/cameras.py +++ b/smart_home/cameras.py @@ -5,6 +5,7 @@ """Utilities for dealing with the webcams.""" import logging +from typing import Optional import scott_secrets import smart_home.device as dev @@ -29,9 +30,12 @@ class BaseCamera(dev.Device): super().__init__(name.strip(), mac.strip(), keywords) self.camera_name = BaseCamera.camera_mapping.get(name, None) - def get_stream_url(self) -> str: + def get_stream_url(self) -> Optional[str]: + """Get the URL for the webcam's live stream. Return None on error.""" + name = self.camera_name - assert name is not None + if not name: + return None if name == 'driveway': return f'http://10.0.0.226:8080/{scott_secrets.SHINOBI_KEY1}/mjpeg/{scott_secrets.SHINOBI_KEY2}/driveway' else: