Move imports in mobile_app component (#28027)

This commit is contained in:
Diefferson Koderer Môro 2019-10-21 05:05:41 -03:00 committed by Fabian Affolter
parent 206f8cef5c
commit 3e9d28f28a
11 changed files with 24 additions and 35 deletions

View file

@ -1,6 +1,6 @@
"""Integrates Native Apps to Home Assistant.""" """Integrates Native Apps to Home Assistant."""
from homeassistant.const import CONF_WEBHOOK_ID
from homeassistant.components.webhook import async_register as webhook_register from homeassistant.components.webhook import async_register as webhook_register
from homeassistant.const import CONF_WEBHOOK_ID
from homeassistant.helpers import device_registry as dr, discovery from homeassistant.helpers import device_registry as dr, discovery
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType, HomeAssistantType
@ -20,7 +20,6 @@ from .const import (
STORAGE_KEY, STORAGE_KEY,
STORAGE_VERSION, STORAGE_VERSION,
) )
from .http_api import RegistrationsView from .http_api import RegistrationsView
from .webhook import handle_webhook from .webhook import handle_webhook
from .websocket_api import register_websocket_handlers from .websocket_api import register_websocket_handlers

View file

@ -1,9 +1,9 @@
"""Binary sensor platform for mobile_app.""" """Binary sensor platform for mobile_app."""
from functools import partial from functools import partial
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.const import CONF_WEBHOOK_ID from homeassistant.const import CONF_WEBHOOK_ID
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from .const import ( from .const import (
@ -13,7 +13,6 @@ from .const import (
DATA_DEVICES, DATA_DEVICES,
DOMAIN, DOMAIN,
) )
from .entity import MobileAppEntity, sensor_id from .entity import MobileAppEntity, sensor_id

View file

@ -1,6 +1,7 @@
"""Config flow for Mobile App.""" """Config flow for Mobile App."""
from homeassistant import config_entries from homeassistant import config_entries
from .const import DOMAIN, ATTR_DEVICE_NAME
from .const import ATTR_DEVICE_NAME, DOMAIN
@config_entries.HANDLERS.register(DOMAIN) @config_entries.HANDLERS.register(DOMAIN)

View file

@ -4,13 +4,13 @@ import voluptuous as vol
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASSES as BINARY_SENSOR_CLASSES, DEVICE_CLASSES as BINARY_SENSOR_CLASSES,
) )
from homeassistant.components.sensor import DEVICE_CLASSES as SENSOR_CLASSES
from homeassistant.components.device_tracker import ( from homeassistant.components.device_tracker import (
ATTR_BATTERY, ATTR_BATTERY,
ATTR_GPS, ATTR_GPS,
ATTR_GPS_ACCURACY, ATTR_GPS_ACCURACY,
ATTR_LOCATION_NAME, ATTR_LOCATION_NAME,
) )
from homeassistant.components.sensor import DEVICE_CLASSES as SENSOR_CLASSES
from homeassistant.const import ATTR_DOMAIN, ATTR_SERVICE, ATTR_SERVICE_DATA from homeassistant.const import ATTR_DOMAIN, ATTR_SERVICE, ATTR_SERVICE_DATA
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv

View file

@ -1,19 +1,20 @@
"""Device tracker platform that adds support for OwnTracks over MQTT.""" """Device tracker platform that adds support for OwnTracks over MQTT."""
import logging import logging
from homeassistant.core import callback
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, ATTR_BATTERY_LEVEL
from homeassistant.components.device_tracker.const import SOURCE_TYPE_GPS
from homeassistant.components.device_tracker.config_entry import TrackerEntity from homeassistant.components.device_tracker.config_entry import TrackerEntity
from homeassistant.components.device_tracker.const import SOURCE_TYPE_GPS
from homeassistant.const import ATTR_BATTERY_LEVEL, ATTR_LATITUDE, ATTR_LONGITUDE
from homeassistant.core import callback
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from .const import ( from .const import (
ATTR_ALTITUDE, ATTR_ALTITUDE,
ATTR_BATTERY, ATTR_BATTERY,
ATTR_COURSE, ATTR_COURSE,
ATTR_DEVICE_ID, ATTR_DEVICE_ID,
ATTR_DEVICE_NAME, ATTR_DEVICE_NAME,
ATTR_GPS_ACCURACY,
ATTR_GPS, ATTR_GPS,
ATTR_GPS_ACCURACY,
ATTR_LOCATION_NAME, ATTR_LOCATION_NAME,
ATTR_SPEED, ATTR_SPEED,
ATTR_VERTICAL_ACCURACY, ATTR_VERTICAL_ACCURACY,

View file

@ -1,9 +1,11 @@
"""Helpers for mobile_app.""" """Helpers for mobile_app."""
import logging
import json import json
import logging
from typing import Callable, Dict, Tuple from typing import Callable, Dict, Tuple
from aiohttp.web import json_response, Response from aiohttp.web import Response, json_response
from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox
from homeassistant.core import Context from homeassistant.core import Context
from homeassistant.helpers.json import JSONEncoder from homeassistant.helpers.json import JSONEncoder
@ -13,8 +15,8 @@ from .const import (
ATTR_APP_DATA, ATTR_APP_DATA,
ATTR_APP_ID, ATTR_APP_ID,
ATTR_APP_NAME, ATTR_APP_NAME,
ATTR_DEVICE_ID,
ATTR_APP_VERSION, ATTR_APP_VERSION,
ATTR_DEVICE_ID,
ATTR_DEVICE_NAME, ATTR_DEVICE_NAME,
ATTR_MANUFACTURER, ATTR_MANUFACTURER,
ATTR_MODEL, ATTR_MODEL,
@ -36,8 +38,6 @@ def setup_decrypt() -> Tuple[int, Callable]:
Async friendly. Async friendly.
""" """
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder
def decrypt(ciphertext, key): def decrypt(ciphertext, key):
"""Decrypt ciphertext using key.""" """Decrypt ciphertext using key."""
@ -51,8 +51,6 @@ def setup_encrypt() -> Tuple[int, Callable]:
Async friendly. Async friendly.
""" """
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder
def encrypt(ciphertext, key): def encrypt(ciphertext, key):
"""Encrypt ciphertext using key.""" """Encrypt ciphertext using key."""

View file

@ -1,18 +1,19 @@
"""Provides an HTTP API for mobile_app.""" """Provides an HTTP API for mobile_app."""
import uuid
from typing import Dict from typing import Dict
import uuid
from aiohttp.web import Response, Request from aiohttp.web import Request, Response
from nacl.secret import SecretBox
from homeassistant.auth.util import generate_secret from homeassistant.auth.util import generate_secret
from homeassistant.components.cloud import ( from homeassistant.components.cloud import (
CloudNotAvailable,
async_create_cloudhook, async_create_cloudhook,
async_remote_ui_url, async_remote_ui_url,
CloudNotAvailable,
) )
from homeassistant.components.http import HomeAssistantView from homeassistant.components.http import HomeAssistantView
from homeassistant.components.http.data_validator import RequestDataValidator from homeassistant.components.http.data_validator import RequestDataValidator
from homeassistant.const import HTTP_CREATED, CONF_WEBHOOK_ID from homeassistant.const import CONF_WEBHOOK_ID, HTTP_CREATED
from .const import ( from .const import (
ATTR_DEVICE_ID, ATTR_DEVICE_ID,
@ -24,7 +25,6 @@ from .const import (
DOMAIN, DOMAIN,
REGISTRATION_SCHEMA, REGISTRATION_SCHEMA,
) )
from .helpers import supports_encryption from .helpers import supports_encryption
@ -49,8 +49,6 @@ class RegistrationsView(HomeAssistantView):
data[CONF_WEBHOOK_ID] = webhook_id data[CONF_WEBHOOK_ID] = webhook_id
if data[ATTR_SUPPORTS_ENCRYPTION] and supports_encryption(): if data[ATTR_SUPPORTS_ENCRYPTION] and supports_encryption():
from nacl.secret import SecretBox
data[CONF_SECRET] = generate_secret(SecretBox.KEY_SIZE) data[CONF_SECRET] = generate_secret(SecretBox.KEY_SIZE)
data[CONF_USER_ID] = request["hass_user"].id data[CONF_USER_ID] = request["hass_user"].id

View file

@ -12,7 +12,6 @@ from homeassistant.components.notify import (
ATTR_TITLE_DEFAULT, ATTR_TITLE_DEFAULT,
BaseNotificationService, BaseNotificationService,
) )
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util

View file

@ -13,7 +13,6 @@ from .const import (
DATA_DEVICES, DATA_DEVICES,
DOMAIN, DOMAIN,
) )
from .entity import MobileAppEntity, sensor_id from .entity import MobileAppEntity, sensor_id

View file

@ -1,13 +1,12 @@
"""Webhook handlers for mobile_app.""" """Webhook handlers for mobile_app."""
import logging import logging
from aiohttp.web import HTTPBadRequest, Response, Request from aiohttp.web import HTTPBadRequest, Request, Response
import voluptuous as vol import voluptuous as vol
from homeassistant.components.cloud import async_remote_ui_url, CloudNotAvailable from homeassistant.components.cloud import CloudNotAvailable, async_remote_ui_url
from homeassistant.components.frontend import MANIFEST_JSON from homeassistant.components.frontend import MANIFEST_JSON
from homeassistant.components.zone.const import DOMAIN as ZONE_DOMAIN from homeassistant.components.zone.const import DOMAIN as ZONE_DOMAIN
from homeassistant.const import ( from homeassistant.const import (
ATTR_DOMAIN, ATTR_DOMAIN,
ATTR_SERVICE, ATTR_SERVICE,
@ -50,10 +49,10 @@ from .const import (
ERR_ENCRYPTION_REQUIRED, ERR_ENCRYPTION_REQUIRED,
ERR_SENSOR_DUPLICATE_UNIQUE_ID, ERR_SENSOR_DUPLICATE_UNIQUE_ID,
ERR_SENSOR_NOT_REGISTERED, ERR_SENSOR_NOT_REGISTERED,
SIGNAL_LOCATION_UPDATE,
SIGNAL_SENSOR_UPDATE, SIGNAL_SENSOR_UPDATE,
WEBHOOK_PAYLOAD_SCHEMA, WEBHOOK_PAYLOAD_SCHEMA,
WEBHOOK_SCHEMAS, WEBHOOK_SCHEMAS,
WEBHOOK_TYPES,
WEBHOOK_TYPE_CALL_SERVICE, WEBHOOK_TYPE_CALL_SERVICE,
WEBHOOK_TYPE_FIRE_EVENT, WEBHOOK_TYPE_FIRE_EVENT,
WEBHOOK_TYPE_GET_CONFIG, WEBHOOK_TYPE_GET_CONFIG,
@ -63,10 +62,8 @@ from .const import (
WEBHOOK_TYPE_UPDATE_LOCATION, WEBHOOK_TYPE_UPDATE_LOCATION,
WEBHOOK_TYPE_UPDATE_REGISTRATION, WEBHOOK_TYPE_UPDATE_REGISTRATION,
WEBHOOK_TYPE_UPDATE_SENSOR_STATES, WEBHOOK_TYPE_UPDATE_SENSOR_STATES,
SIGNAL_LOCATION_UPDATE, WEBHOOK_TYPES,
) )
from .helpers import ( from .helpers import (
_decrypt_payload, _decrypt_payload,
empty_okay_response, empty_okay_response,
@ -77,7 +74,6 @@ from .helpers import (
webhook_response, webhook_response,
) )
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -29,7 +29,6 @@ from .const import (
DATA_STORE, DATA_STORE,
DOMAIN, DOMAIN,
) )
from .helpers import safe_registration, savable_state from .helpers import safe_registration, savable_state