diff --git a/homeassistant/components/ring/__init__.py b/homeassistant/components/ring/__init__.py index 006b3ae3e9a..a68749b2c67 100644 --- a/homeassistant/components/ring/__init__.py +++ b/homeassistant/components/ring/__init__.py @@ -1,14 +1,15 @@ """Support for Ring Doorbell/Chimes.""" +from datetime import timedelta import logging -from datetime import timedelta from requests.exceptions import ConnectTimeout, HTTPError +from ring_doorbell import Ring import voluptuous as vol -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, CONF_SCAN_INTERVAL -from homeassistant.helpers.event import track_time_interval -from homeassistant.helpers.dispatcher import dispatcher_send +from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.dispatcher import dispatcher_send +from homeassistant.helpers.event import track_time_interval _LOGGER = logging.getLogger(__name__) @@ -50,8 +51,6 @@ def setup(hass, config): scan_interval = conf[CONF_SCAN_INTERVAL] try: - from ring_doorbell import Ring - cache = hass.config.path(DEFAULT_CACHEDB) ring = Ring(username=username, password=password, cache_file=cache) if not ring.is_connected: diff --git a/homeassistant/components/ring/camera.py b/homeassistant/components/ring/camera.py index 461b3a199d7..1d2fe6ff67b 100644 --- a/homeassistant/components/ring/camera.py +++ b/homeassistant/components/ring/camera.py @@ -3,16 +3,18 @@ import asyncio from datetime import timedelta import logging +from haffmpeg.camera import CameraMjpeg +from haffmpeg.tools import IMAGE_JPEG, ImageFrame import voluptuous as vol from homeassistant.components.camera import PLATFORM_SCHEMA, Camera from homeassistant.components.ffmpeg import DATA_FFMPEG from homeassistant.const import ATTR_ATTRIBUTION +from homeassistant.core import callback from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_aiohttp_proxy_stream -from homeassistant.util import dt as dt_util from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.core import callback +from homeassistant.util import dt as dt_util from . import ( ATTRIBUTION, @@ -122,7 +124,6 @@ class RingCam(Camera): async def async_camera_image(self): """Return a still image response from the camera.""" - from haffmpeg.tools import ImageFrame, IMAGE_JPEG ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop) @@ -140,7 +141,6 @@ class RingCam(Camera): async def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" - from haffmpeg.camera import CameraMjpeg if self._video_url is None: return diff --git a/homeassistant/components/ring/light.py b/homeassistant/components/ring/light.py index 697be4d1579..bc86e5b5fd1 100644 --- a/homeassistant/components/ring/light.py +++ b/homeassistant/components/ring/light.py @@ -1,9 +1,10 @@ """This component provides HA switch support for Ring Door Bell/Chimes.""" -import logging from datetime import timedelta +import logging + from homeassistant.components.light import Light -from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.core import callback +from homeassistant.helpers.dispatcher import async_dispatcher_connect import homeassistant.util.dt as dt_util from . import DATA_RING_STICKUP_CAMS, SIGNAL_UPDATE_RING diff --git a/homeassistant/components/ring/sensor.py b/homeassistant/components/ring/sensor.py index 6a64226a053..b54c750664e 100644 --- a/homeassistant/components/ring/sensor.py +++ b/homeassistant/components/ring/sensor.py @@ -9,11 +9,11 @@ from homeassistant.const import ( CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS, ) +from homeassistant.core import callback import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import Entity from homeassistant.helpers.icon import icon_for_battery_level -from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.core import callback from . import ( ATTRIBUTION, diff --git a/homeassistant/components/ring/switch.py b/homeassistant/components/ring/switch.py index 413d2a70aae..16fc4a6717f 100644 --- a/homeassistant/components/ring/switch.py +++ b/homeassistant/components/ring/switch.py @@ -1,9 +1,10 @@ """This component provides HA switch support for Ring Door Bell/Chimes.""" -import logging from datetime import timedelta +import logging + from homeassistant.components.switch import SwitchDevice -from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.core import callback +from homeassistant.helpers.dispatcher import async_dispatcher_connect import homeassistant.util.dt as dt_util from . import DATA_RING_STICKUP_CAMS, SIGNAL_UPDATE_RING