Use global imports for ESPHome (#24158)

* Use global import for ESPHome

* Add aioesphomeapi to test requirements

aioesphomeapi is also shipped as a pure-python wheel, so this should not impact test install time
This commit is contained in:
Otto Winter
2019-05-29 13:33:49 +02:00
committed by Pascal Vizeli
parent d9c78b77cb
commit 015c8811a5
11 changed files with 69 additions and 118 deletions

View File

@@ -1,17 +1,16 @@
"""Support for ESPHome cameras."""
import asyncio
import logging
from typing import Optional, TYPE_CHECKING
from typing import Optional
from aioesphomeapi import CameraInfo, CameraState
from homeassistant.components import camera
from homeassistant.components.camera import Camera
from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType
from . import EsphomeEntity, platform_async_setup_entry
if TYPE_CHECKING:
# pylint: disable=unused-import
from aioesphomeapi import CameraInfo, CameraState # noqa
from . import EsphomeEntity, platform_async_setup_entry
_LOGGER = logging.getLogger(__name__)
@@ -19,9 +18,6 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry(hass: HomeAssistantType,
entry: ConfigEntry, async_add_entities) -> None:
"""Set up esphome cameras based on a config entry."""
# pylint: disable=redefined-outer-name
from aioesphomeapi import CameraInfo, CameraState # noqa
await platform_async_setup_entry(
hass, entry, async_add_entities,
component_key='camera',
@@ -40,11 +36,11 @@ class EsphomeCamera(Camera, EsphomeEntity):
self._image_cond = asyncio.Condition()
@property
def _static_info(self) -> 'CameraInfo':
def _static_info(self) -> CameraInfo:
return super()._static_info
@property
def _state(self) -> Optional['CameraState']:
def _state(self) -> Optional[CameraState]:
return super()._state
async def _on_update(self) -> None: