Move imports in august component (#27810)
This commit is contained in:
parent
1a5b4c105a
commit
bb80d9bd16
3 changed files with 12 additions and 18 deletions
|
@ -1,18 +1,20 @@
|
||||||
"""Support for August devices."""
|
"""Support for August devices."""
|
||||||
import logging
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from august.api import Api
|
||||||
|
from august.authenticator import AuthenticationState, Authenticator, ValidationResult
|
||||||
|
from requests import RequestException, Session
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from requests import RequestException
|
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_USERNAME,
|
|
||||||
CONF_TIMEOUT,
|
CONF_TIMEOUT,
|
||||||
|
CONF_USERNAME,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -62,7 +64,6 @@ def request_configuration(hass, config, api, authenticator):
|
||||||
|
|
||||||
def august_configuration_callback(data):
|
def august_configuration_callback(data):
|
||||||
"""Run when the configuration callback is called."""
|
"""Run when the configuration callback is called."""
|
||||||
from august.authenticator import ValidationResult
|
|
||||||
|
|
||||||
result = authenticator.validate_verification_code(data.get("verification_code"))
|
result = authenticator.validate_verification_code(data.get("verification_code"))
|
||||||
|
|
||||||
|
@ -94,7 +95,6 @@ def request_configuration(hass, config, api, authenticator):
|
||||||
|
|
||||||
def setup_august(hass, config, api, authenticator):
|
def setup_august(hass, config, api, authenticator):
|
||||||
"""Set up the August component."""
|
"""Set up the August component."""
|
||||||
from august.authenticator import AuthenticationState
|
|
||||||
|
|
||||||
authentication = None
|
authentication = None
|
||||||
try:
|
try:
|
||||||
|
@ -134,9 +134,6 @@ def setup_august(hass, config, api, authenticator):
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Set up the August component."""
|
"""Set up the August component."""
|
||||||
from august.api import Api
|
|
||||||
from august.authenticator import Authenticator
|
|
||||||
from requests import Session
|
|
||||||
|
|
||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
api_http_session = None
|
api_http_session = None
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from august.activity import ActivityType
|
||||||
|
from august.lock import LockDoorStatus
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||||
|
|
||||||
from . import DATA_AUGUST
|
from . import DATA_AUGUST
|
||||||
|
@ -26,7 +29,6 @@ def _retrieve_online_state(data, doorbell):
|
||||||
|
|
||||||
|
|
||||||
def _retrieve_motion_state(data, doorbell):
|
def _retrieve_motion_state(data, doorbell):
|
||||||
from august.activity import ActivityType
|
|
||||||
|
|
||||||
return _activity_time_based_state(
|
return _activity_time_based_state(
|
||||||
data, doorbell, [ActivityType.DOORBELL_MOTION, ActivityType.DOORBELL_DING]
|
data, doorbell, [ActivityType.DOORBELL_MOTION, ActivityType.DOORBELL_DING]
|
||||||
|
@ -34,7 +36,6 @@ def _retrieve_motion_state(data, doorbell):
|
||||||
|
|
||||||
|
|
||||||
def _retrieve_ding_state(data, doorbell):
|
def _retrieve_ding_state(data, doorbell):
|
||||||
from august.activity import ActivityType
|
|
||||||
|
|
||||||
return _activity_time_based_state(data, doorbell, [ActivityType.DOORBELL_DING])
|
return _activity_time_based_state(data, doorbell, [ActivityType.DOORBELL_DING])
|
||||||
|
|
||||||
|
@ -65,8 +66,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
data = hass.data[DATA_AUGUST]
|
data = hass.data[DATA_AUGUST]
|
||||||
devices = []
|
devices = []
|
||||||
|
|
||||||
from august.lock import LockDoorStatus
|
|
||||||
|
|
||||||
for door in data.locks:
|
for door in data.locks:
|
||||||
for sensor_type in SENSOR_TYPES_DOOR:
|
for sensor_type in SENSOR_TYPES_DOOR:
|
||||||
state_provider = SENSOR_TYPES_DOOR[sensor_type][2]
|
state_provider = SENSOR_TYPES_DOOR[sensor_type][2]
|
||||||
|
@ -136,8 +135,6 @@ class AugustDoorBinarySensor(BinarySensorDevice):
|
||||||
self._state = state_provider(self._data, self._door)
|
self._state = state_provider(self._data, self._door)
|
||||||
self._available = self._state is not None
|
self._available = self._state is not None
|
||||||
|
|
||||||
from august.lock import LockDoorStatus
|
|
||||||
|
|
||||||
self._state = self._state == LockDoorStatus.OPEN
|
self._state = self._state == LockDoorStatus.OPEN
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from august.activity import ActivityType
|
||||||
|
from august.lock import LockStatus
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockDevice
|
||||||
from homeassistant.const import ATTR_BATTERY_LEVEL
|
from homeassistant.const import ATTR_BATTERY_LEVEL
|
||||||
|
|
||||||
|
@ -51,8 +54,6 @@ class AugustLock(LockDevice):
|
||||||
|
|
||||||
self._lock_detail = self._data.get_lock_detail(self._lock.device_id)
|
self._lock_detail = self._data.get_lock_detail(self._lock.device_id)
|
||||||
|
|
||||||
from august.activity import ActivityType
|
|
||||||
|
|
||||||
activity = self._data.get_latest_device_activity(
|
activity = self._data.get_latest_device_activity(
|
||||||
self._lock.device_id, ActivityType.LOCK_OPERATION
|
self._lock.device_id, ActivityType.LOCK_OPERATION
|
||||||
)
|
)
|
||||||
|
@ -73,7 +74,6 @@ class AugustLock(LockDevice):
|
||||||
@property
|
@property
|
||||||
def is_locked(self):
|
def is_locked(self):
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
from august.lock import LockStatus
|
|
||||||
|
|
||||||
return self._lock_status is LockStatus.LOCKED
|
return self._lock_status is LockStatus.LOCKED
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue