mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Move imports to top for ring (#29474)
This commit is contained in:
parent
c02d551cd5
commit
c6066d8b98
@ -1,14 +1,15 @@
|
|||||||
"""Support for Ring Doorbell/Chimes."""
|
"""Support for Ring Doorbell/Chimes."""
|
||||||
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from datetime import timedelta
|
|
||||||
from requests.exceptions import ConnectTimeout, HTTPError
|
from requests.exceptions import ConnectTimeout, HTTPError
|
||||||
|
from ring_doorbell import Ring
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, CONF_SCAN_INTERVAL
|
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
|
||||||
from homeassistant.helpers.event import track_time_interval
|
|
||||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -50,8 +51,6 @@ def setup(hass, config):
|
|||||||
scan_interval = conf[CONF_SCAN_INTERVAL]
|
scan_interval = conf[CONF_SCAN_INTERVAL]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ring_doorbell import Ring
|
|
||||||
|
|
||||||
cache = hass.config.path(DEFAULT_CACHEDB)
|
cache = hass.config.path(DEFAULT_CACHEDB)
|
||||||
ring = Ring(username=username, password=password, cache_file=cache)
|
ring = Ring(username=username, password=password, cache_file=cache)
|
||||||
if not ring.is_connected:
|
if not ring.is_connected:
|
||||||
|
@ -3,16 +3,18 @@ import asyncio
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from haffmpeg.camera import CameraMjpeg
|
||||||
|
from haffmpeg.tools import IMAGE_JPEG, ImageFrame
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera
|
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera
|
||||||
from homeassistant.components.ffmpeg import DATA_FFMPEG
|
from homeassistant.components.ffmpeg import DATA_FFMPEG
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.aiohttp_client import async_aiohttp_proxy_stream
|
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.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.core import callback
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
ATTRIBUTION,
|
ATTRIBUTION,
|
||||||
@ -122,7 +124,6 @@ class RingCam(Camera):
|
|||||||
|
|
||||||
async def async_camera_image(self):
|
async def async_camera_image(self):
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
from haffmpeg.tools import ImageFrame, IMAGE_JPEG
|
|
||||||
|
|
||||||
ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop)
|
ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop)
|
||||||
|
|
||||||
@ -140,7 +141,6 @@ class RingCam(Camera):
|
|||||||
|
|
||||||
async def handle_async_mjpeg_stream(self, request):
|
async def handle_async_mjpeg_stream(self, request):
|
||||||
"""Generate an HTTP MJPEG stream from the camera."""
|
"""Generate an HTTP MJPEG stream from the camera."""
|
||||||
from haffmpeg.camera import CameraMjpeg
|
|
||||||
|
|
||||||
if self._video_url is None:
|
if self._video_url is None:
|
||||||
return
|
return
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
"""This component provides HA switch support for Ring Door Bell/Chimes."""
|
"""This component provides HA switch support for Ring Door Bell/Chimes."""
|
||||||
import logging
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.light import Light
|
from homeassistant.components.light import Light
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from . import DATA_RING_STICKUP_CAMS, SIGNAL_UPDATE_RING
|
from . import DATA_RING_STICKUP_CAMS, SIGNAL_UPDATE_RING
|
||||||
|
@ -9,11 +9,11 @@ from homeassistant.const import (
|
|||||||
CONF_ENTITY_NAMESPACE,
|
CONF_ENTITY_NAMESPACE,
|
||||||
CONF_MONITORED_CONDITIONS,
|
CONF_MONITORED_CONDITIONS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.icon import icon_for_battery_level
|
from homeassistant.helpers.icon import icon_for_battery_level
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|
||||||
from homeassistant.core import callback
|
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
ATTRIBUTION,
|
ATTRIBUTION,
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
"""This component provides HA switch support for Ring Door Bell/Chimes."""
|
"""This component provides HA switch support for Ring Door Bell/Chimes."""
|
||||||
import logging
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from . import DATA_RING_STICKUP_CAMS, SIGNAL_UPDATE_RING
|
from . import DATA_RING_STICKUP_CAMS, SIGNAL_UPDATE_RING
|
||||||
|
Loading…
x
Reference in New Issue
Block a user