Move imports in canary component (#27874)
parent
dc5d38128c
commit
d78f14b20a
|
@ -1,13 +1,14 @@
|
|||
"""Support for Canary devices."""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
from canary.api import Api
|
||||
from requests import ConnectTimeout, HTTPError
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_TIMEOUT
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
|
||||
from homeassistant.helpers import discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -67,7 +68,6 @@ class CanaryData:
|
|||
|
||||
def __init__(self, username, password, timeout):
|
||||
"""Init the Canary data object."""
|
||||
from canary.api import Api
|
||||
|
||||
self._api = Api(username, password, timeout)
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Support for Canary alarm."""
|
||||
import logging
|
||||
|
||||
from canary.api import LOCATION_MODE_AWAY, LOCATION_MODE_HOME, LOCATION_MODE_NIGHT
|
||||
|
||||
from homeassistant.components.alarm_control_panel import AlarmControlPanel
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_ARMED_AWAY,
|
||||
|
@ -42,11 +44,6 @@ class CanaryAlarm(AlarmControlPanel):
|
|||
@property
|
||||
def state(self):
|
||||
"""Return the state of the device."""
|
||||
from canary.api import (
|
||||
LOCATION_MODE_AWAY,
|
||||
LOCATION_MODE_HOME,
|
||||
LOCATION_MODE_NIGHT,
|
||||
)
|
||||
|
||||
location = self._data.get_location(self._location_id)
|
||||
|
||||
|
@ -75,18 +72,15 @@ class CanaryAlarm(AlarmControlPanel):
|
|||
|
||||
def alarm_arm_home(self, code=None):
|
||||
"""Send arm home command."""
|
||||
from canary.api import LOCATION_MODE_HOME
|
||||
|
||||
self._data.set_location_mode(self._location_id, LOCATION_MODE_HOME)
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
"""Send arm away command."""
|
||||
from canary.api import LOCATION_MODE_AWAY
|
||||
|
||||
self._data.set_location_mode(self._location_id, LOCATION_MODE_AWAY)
|
||||
|
||||
def alarm_arm_night(self, code=None):
|
||||
"""Send arm night command."""
|
||||
from canary.api import LOCATION_MODE_NIGHT
|
||||
|
||||
self._data.set_location_mode(self._location_id, LOCATION_MODE_NIGHT)
|
||||
|
|
|
@ -3,6 +3,8 @@ 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
|
||||
|
@ -81,8 +83,6 @@ class CanaryCamera(Camera):
|
|||
"""Return a still image response from the camera."""
|
||||
self.renew_live_stream_session()
|
||||
|
||||
from haffmpeg.tools import ImageFrame, IMAGE_JPEG
|
||||
|
||||
ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop)
|
||||
image = await asyncio.shield(
|
||||
ffmpeg.get_image(
|
||||
|
@ -98,8 +98,6 @@ class CanaryCamera(Camera):
|
|||
if self._live_stream_session is None:
|
||||
return
|
||||
|
||||
from haffmpeg.camera import CameraMjpeg
|
||||
|
||||
stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop)
|
||||
await stream.open_camera(
|
||||
self._live_stream_session.live_stream_url, extra_cmd=self._ffmpeg_arguments
|
||||
|
|
Loading…
Reference in New Issue