Move imports in mobile_app component (#28027)
parent
206f8cef5c
commit
3e9d28f28a
|
@ -1,6 +1,6 @@
|
|||
"""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.const import CONF_WEBHOOK_ID
|
||||
from homeassistant.helpers import device_registry as dr, discovery
|
||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||
|
||||
|
@ -20,7 +20,6 @@ from .const import (
|
|||
STORAGE_KEY,
|
||||
STORAGE_VERSION,
|
||||
)
|
||||
|
||||
from .http_api import RegistrationsView
|
||||
from .webhook import handle_webhook
|
||||
from .websocket_api import register_websocket_handlers
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""Binary sensor platform for mobile_app."""
|
||||
from functools import partial
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.const import CONF_WEBHOOK_ID
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
from .const import (
|
||||
|
@ -13,7 +13,6 @@ from .const import (
|
|||
DATA_DEVICES,
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
from .entity import MobileAppEntity, sensor_id
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Config flow for Mobile App."""
|
||||
from homeassistant import config_entries
|
||||
from .const import DOMAIN, ATTR_DEVICE_NAME
|
||||
|
||||
from .const import ATTR_DEVICE_NAME, DOMAIN
|
||||
|
||||
|
||||
@config_entries.HANDLERS.register(DOMAIN)
|
||||
|
|
|
@ -4,13 +4,13 @@ import voluptuous as vol
|
|||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASSES as BINARY_SENSOR_CLASSES,
|
||||
)
|
||||
from homeassistant.components.sensor import DEVICE_CLASSES as SENSOR_CLASSES
|
||||
from homeassistant.components.device_tracker import (
|
||||
ATTR_BATTERY,
|
||||
ATTR_GPS,
|
||||
ATTR_GPS_ACCURACY,
|
||||
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.helpers import config_validation as cv
|
||||
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
"""Device tracker platform that adds support for OwnTracks over MQTT."""
|
||||
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.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 .const import (
|
||||
ATTR_ALTITUDE,
|
||||
ATTR_BATTERY,
|
||||
ATTR_COURSE,
|
||||
ATTR_DEVICE_ID,
|
||||
ATTR_DEVICE_NAME,
|
||||
ATTR_GPS_ACCURACY,
|
||||
ATTR_GPS,
|
||||
ATTR_GPS_ACCURACY,
|
||||
ATTR_LOCATION_NAME,
|
||||
ATTR_SPEED,
|
||||
ATTR_VERTICAL_ACCURACY,
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
"""Helpers for mobile_app."""
|
||||
import logging
|
||||
import json
|
||||
import logging
|
||||
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.helpers.json import JSONEncoder
|
||||
|
@ -13,8 +15,8 @@ from .const import (
|
|||
ATTR_APP_DATA,
|
||||
ATTR_APP_ID,
|
||||
ATTR_APP_NAME,
|
||||
ATTR_DEVICE_ID,
|
||||
ATTR_APP_VERSION,
|
||||
ATTR_DEVICE_ID,
|
||||
ATTR_DEVICE_NAME,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
|
@ -36,8 +38,6 @@ def setup_decrypt() -> Tuple[int, Callable]:
|
|||
|
||||
Async friendly.
|
||||
"""
|
||||
from nacl.secret import SecretBox
|
||||
from nacl.encoding import Base64Encoder
|
||||
|
||||
def decrypt(ciphertext, key):
|
||||
"""Decrypt ciphertext using key."""
|
||||
|
@ -51,8 +51,6 @@ def setup_encrypt() -> Tuple[int, Callable]:
|
|||
|
||||
Async friendly.
|
||||
"""
|
||||
from nacl.secret import SecretBox
|
||||
from nacl.encoding import Base64Encoder
|
||||
|
||||
def encrypt(ciphertext, key):
|
||||
"""Encrypt ciphertext using key."""
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
"""Provides an HTTP API for mobile_app."""
|
||||
import uuid
|
||||
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.components.cloud import (
|
||||
CloudNotAvailable,
|
||||
async_create_cloudhook,
|
||||
async_remote_ui_url,
|
||||
CloudNotAvailable,
|
||||
)
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
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 (
|
||||
ATTR_DEVICE_ID,
|
||||
|
@ -24,7 +25,6 @@ from .const import (
|
|||
DOMAIN,
|
||||
REGISTRATION_SCHEMA,
|
||||
)
|
||||
|
||||
from .helpers import supports_encryption
|
||||
|
||||
|
||||
|
@ -49,8 +49,6 @@ class RegistrationsView(HomeAssistantView):
|
|||
data[CONF_WEBHOOK_ID] = webhook_id
|
||||
|
||||
if data[ATTR_SUPPORTS_ENCRYPTION] and supports_encryption():
|
||||
from nacl.secret import SecretBox
|
||||
|
||||
data[CONF_SECRET] = generate_secret(SecretBox.KEY_SIZE)
|
||||
|
||||
data[CONF_USER_ID] = request["hass_user"].id
|
||||
|
|
|
@ -12,7 +12,6 @@ from homeassistant.components.notify import (
|
|||
ATTR_TITLE_DEFAULT,
|
||||
BaseNotificationService,
|
||||
)
|
||||
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ from .const import (
|
|||
DATA_DEVICES,
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
from .entity import MobileAppEntity, sensor_id
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
"""Webhook handlers for mobile_app."""
|
||||
import logging
|
||||
|
||||
from aiohttp.web import HTTPBadRequest, Response, Request
|
||||
from aiohttp.web import HTTPBadRequest, Request, Response
|
||||
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.zone.const import DOMAIN as ZONE_DOMAIN
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_DOMAIN,
|
||||
ATTR_SERVICE,
|
||||
|
@ -50,10 +49,10 @@ from .const import (
|
|||
ERR_ENCRYPTION_REQUIRED,
|
||||
ERR_SENSOR_DUPLICATE_UNIQUE_ID,
|
||||
ERR_SENSOR_NOT_REGISTERED,
|
||||
SIGNAL_LOCATION_UPDATE,
|
||||
SIGNAL_SENSOR_UPDATE,
|
||||
WEBHOOK_PAYLOAD_SCHEMA,
|
||||
WEBHOOK_SCHEMAS,
|
||||
WEBHOOK_TYPES,
|
||||
WEBHOOK_TYPE_CALL_SERVICE,
|
||||
WEBHOOK_TYPE_FIRE_EVENT,
|
||||
WEBHOOK_TYPE_GET_CONFIG,
|
||||
|
@ -63,10 +62,8 @@ from .const import (
|
|||
WEBHOOK_TYPE_UPDATE_LOCATION,
|
||||
WEBHOOK_TYPE_UPDATE_REGISTRATION,
|
||||
WEBHOOK_TYPE_UPDATE_SENSOR_STATES,
|
||||
SIGNAL_LOCATION_UPDATE,
|
||||
WEBHOOK_TYPES,
|
||||
)
|
||||
|
||||
|
||||
from .helpers import (
|
||||
_decrypt_payload,
|
||||
empty_okay_response,
|
||||
|
@ -77,7 +74,6 @@ from .helpers import (
|
|||
webhook_response,
|
||||
)
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ from .const import (
|
|||
DATA_STORE,
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
from .helpers import safe_registration, savable_state
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue