diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 2915f37dd21..0fc93cfc75c 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -121,7 +121,6 @@ def setup(hass, config): class Camera(Entity): """The base class for camera entities.""" - def __init__(self): """Initialize a camera.""" self.is_streaming = False diff --git a/homeassistant/components/camera/bloomsky.py b/homeassistant/components/camera/bloomsky.py index 6e03a136c6b..feb8b498d26 100644 --- a/homeassistant/components/camera/bloomsky.py +++ b/homeassistant/components/camera/bloomsky.py @@ -1,6 +1,4 @@ """ -homeassistant.components.camera.bloomsky -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for a camera of a BloomSky weather station. For more details about this component, please refer to the documentation at @@ -18,15 +16,14 @@ DEPENDENCIES = ["bloomsky"] # pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): - """ set up access to BloomSky cameras """ + """Setup access to BloomSky cameras.""" bloomsky = get_component('bloomsky') for device in bloomsky.BLOOMSKY.devices.values(): add_devices_callback([BloomSkyCamera(bloomsky.BLOOMSKY, device)]) class BloomSkyCamera(Camera): - """ Represents the images published from the BloomSky's camera. """ - + """Represents the images published from the BloomSky's camera.""" def __init__(self, bs, device): """ set up for access to the BloomSky camera images """ super(BloomSkyCamera, self).__init__() @@ -37,16 +34,16 @@ class BloomSkyCamera(Camera): self._last_url = "" # _last_image will store images as they are downloaded so that the # frequent updates in home-assistant don't keep poking the server - # to download the same image over and over + # to download the same image over and over. self._last_image = "" self._logger = logging.getLogger(__name__) def camera_image(self): - """ Update the camera's image if it has changed. """ + """Update the camera's image if it has changed.""" try: self._url = self._bloomsky.devices[self._id]["Data"]["ImageURL"] self._bloomsky.refresh_devices() - # if the url hasn't changed then the image hasn't changed + # If the URL hasn't changed then the image hasn't changed. if self._url != self._last_url: response = requests.get(self._url, timeout=10) self._last_url = self._url @@ -59,5 +56,5 @@ class BloomSkyCamera(Camera): @property def name(self): - """ The name of this BloomSky device. """ + """The name of this BloomSky device.""" return self._name diff --git a/homeassistant/components/camera/demo.py b/homeassistant/components/camera/demo.py index 15ddeb31d72..0da0a6d195b 100644 --- a/homeassistant/components/camera/demo.py +++ b/homeassistant/components/camera/demo.py @@ -19,7 +19,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class DemoCamera(Camera): """A Demo camera.""" - def __init__(self, name): super().__init__() self._name = name diff --git a/homeassistant/components/camera/foscam.py b/homeassistant/components/camera/foscam.py index 47ebf1b7d5a..7580823390c 100644 --- a/homeassistant/components/camera/foscam.py +++ b/homeassistant/components/camera/foscam.py @@ -1,6 +1,4 @@ """ -homeassistant.components.camera.foscam -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This component provides basic support for Foscam IP cameras. For more details about this platform, please refer to the documentation at @@ -18,7 +16,7 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): - """ Adds a Foscam IP Camera. """ + """Setup a Foscam IP Camera.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['username', 'password', 'ip']}, _LOGGER): return None @@ -28,8 +26,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): # pylint: disable=too-many-instance-attributes class FoscamCamera(Camera): - """ An implementation of a Foscam IP camera. """ - + """An implementation of a Foscam IP camera.""" def __init__(self, device_info): super(FoscamCamera, self).__init__() @@ -48,8 +45,7 @@ class FoscamCamera(Camera): self._name, self._snap_picture_url) def camera_image(self): - """ Return a still image reponse from the camera. """ - + """Return a still image reponse from the camera.""" # Send the request to snap a picture and return raw jpg data response = requests.get(self._snap_picture_url) @@ -57,5 +53,5 @@ class FoscamCamera(Camera): @property def name(self): - """ Return the name of this device. """ + """Return the name of this camera.""" return self._name diff --git a/homeassistant/components/camera/generic.py b/homeassistant/components/camera/generic.py index 514e94db1ef..c563c23c67b 100644 --- a/homeassistant/components/camera/generic.py +++ b/homeassistant/components/camera/generic.py @@ -1,6 +1,4 @@ """ -homeassistant.components.camera.generic -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for IP Cameras. For more details about this platform, please refer to the documentation at @@ -19,7 +17,7 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): - """ Adds a generic IP Camera. """ + """Setup a generic IP Camera.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['still_image_url']}, _LOGGER): return None @@ -32,7 +30,6 @@ class GenericCamera(Camera): """ A generic implementation of an IP camera that is reachable over a URL. """ - def __init__(self, device_info): super().__init__() self._name = device_info.get('name', 'Generic Camera') @@ -41,7 +38,7 @@ class GenericCamera(Camera): self._still_image_url = device_info['still_image_url'] def camera_image(self): - """ Return a still image response from the camera. """ + """Return a still image response from the camera.""" if self._username and self._password: try: response = requests.get( @@ -61,5 +58,5 @@ class GenericCamera(Camera): @property def name(self): - """ Return the name of this device. """ + """Return the name of this device.""" return self._name diff --git a/homeassistant/components/camera/mjpeg.py b/homeassistant/components/camera/mjpeg.py index 95bf9813b39..15710938fdb 100644 --- a/homeassistant/components/camera/mjpeg.py +++ b/homeassistant/components/camera/mjpeg.py @@ -1,6 +1,4 @@ """ -homeassistant.components.camera.mjpeg -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for IP Cameras. For more details about this platform, please refer to the documentation at @@ -23,7 +21,7 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): - """ Adds a mjpeg IP Camera. """ + """Setup a MJPEG IP Camera.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['mjpeg_url']}, _LOGGER): return None @@ -45,7 +43,7 @@ class MjpegCamera(Camera): self._mjpeg_url = device_info['mjpeg_url'] def camera_stream(self): - """ Return a mjpeg stream image response directly from the camera. """ + """Return a MJPEG stream image response directly from the camera.""" if self._username and self._password: return requests.get(self._mjpeg_url, auth=HTTPBasicAuth(self._username, @@ -56,10 +54,9 @@ class MjpegCamera(Camera): stream=True) def camera_image(self): - """ Return a still image response from the camera. """ - + """Return a still image response from the camera.""" def process_response(response): - """ Take in a response object, return the jpg from it. """ + """Take in a response object, return the jpg from it.""" data = b'' for chunk in response.iter_content(1024): data += chunk @@ -73,7 +70,7 @@ class MjpegCamera(Camera): return process_response(response) def mjpeg_stream(self, handler): - """ Generate an HTTP MJPEG stream from the camera. """ + """Generate an HTTP MJPEG stream from the camera.""" response = self.camera_stream() content_type = response.headers[CONTENT_TYPE_HEADER] @@ -88,5 +85,5 @@ class MjpegCamera(Camera): @property def name(self): - """ Return the name of this device. """ + """Return the name of this camera.""" return self._name diff --git a/homeassistant/components/camera/uvc.py b/homeassistant/components/camera/uvc.py index e34b0e26859..2d0f931caf8 100644 --- a/homeassistant/components/camera/uvc.py +++ b/homeassistant/components/camera/uvc.py @@ -1,6 +1,4 @@ """ -homeassistant.components.camera.uvc -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Ubiquiti's UVC cameras. For more details about this platform, please refer to the documentation at @@ -20,7 +18,7 @@ _LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_devices, discovery_info=None): - """ Discover cameras on a Unifi NVR. """ + """Discover cameras on a Unifi NVR.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['nvr', 'key']}, _LOGGER): return None @@ -60,8 +58,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class UnifiVideoCamera(Camera): - """ A Ubiquiti Unifi Video Camera. """ - + """A Ubiquiti Unifi Video Camera.""" def __init__(self, nvr, uuid, name): super(UnifiVideoCamera, self).__init__() self._nvr = nvr @@ -73,23 +70,28 @@ class UnifiVideoCamera(Camera): @property def name(self): + """Return the name of this camera.""" return self._name @property def is_recording(self): + """Return true if the camera is recording.""" caminfo = self._nvr.get_camera(self._uuid) return caminfo['recordingSettings']['fullTimeRecordEnabled'] @property def brand(self): + """Return the brand of this camera.""" return 'Ubiquiti' @property def model(self): + """Return the model of this camera.""" caminfo = self._nvr.get_camera(self._uuid) return caminfo['model'] def _login(self): + """Login to the camera.""" from uvcclient import camera as uvc_camera from uvcclient import store as uvc_store @@ -131,6 +133,7 @@ class UnifiVideoCamera(Camera): return True def camera_image(self): + """Return the image of this camera.""" from uvcclient import camera as uvc_camera if not self._camera: if not self._login():