Move imports in harmony component (#27904)
parent
00521b5e80
commit
1e727f339f
|
@ -3,6 +3,12 @@ import asyncio
|
|||
import json
|
||||
import logging
|
||||
|
||||
import aioharmony.exceptions as aioexc
|
||||
from aioharmony.harmonyapi import (
|
||||
ClientCallbackType,
|
||||
HarmonyAPI as HarmonyClient,
|
||||
SendCommandDevice,
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import remote
|
||||
|
@ -23,8 +29,8 @@ from homeassistant.const import (
|
|||
CONF_PORT,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util import slugify
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -165,8 +171,6 @@ class HarmonyRemote(remote.RemoteDevice):
|
|||
|
||||
def __init__(self, name, host, port, activity, out_path, delay_secs):
|
||||
"""Initialize HarmonyRemote class."""
|
||||
from aioharmony.harmonyapi import HarmonyAPI as HarmonyClient
|
||||
|
||||
self._name = name
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
@ -180,8 +184,6 @@ class HarmonyRemote(remote.RemoteDevice):
|
|||
|
||||
async def async_added_to_hass(self):
|
||||
"""Complete the initialization."""
|
||||
from aioharmony.harmonyapi import ClientCallbackType
|
||||
|
||||
_LOGGER.debug("%s: Harmony Hub added", self._name)
|
||||
# Register the callbacks
|
||||
self._client.callbacks = ClientCallbackType(
|
||||
|
@ -195,8 +197,6 @@ class HarmonyRemote(remote.RemoteDevice):
|
|||
# activity
|
||||
await self.new_config()
|
||||
|
||||
import aioharmony.exceptions as aioexc
|
||||
|
||||
async def shutdown(_):
|
||||
"""Close connection on shutdown."""
|
||||
_LOGGER.debug("%s: Closing Harmony Hub", self._name)
|
||||
|
@ -234,8 +234,6 @@ class HarmonyRemote(remote.RemoteDevice):
|
|||
|
||||
async def connect(self):
|
||||
"""Connect to the Harmony HUB."""
|
||||
import aioharmony.exceptions as aioexc
|
||||
|
||||
_LOGGER.debug("%s: Connecting", self._name)
|
||||
try:
|
||||
if not await self._client.connect():
|
||||
|
@ -284,8 +282,6 @@ class HarmonyRemote(remote.RemoteDevice):
|
|||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
"""Start an activity from the Harmony device."""
|
||||
import aioharmony.exceptions as aioexc
|
||||
|
||||
_LOGGER.debug("%s: Turn On", self.name)
|
||||
|
||||
activity = kwargs.get(ATTR_ACTIVITY, self._default_activity)
|
||||
|
@ -314,8 +310,6 @@ class HarmonyRemote(remote.RemoteDevice):
|
|||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Start the PowerOff activity."""
|
||||
import aioharmony.exceptions as aioexc
|
||||
|
||||
_LOGGER.debug("%s: Turn Off", self.name)
|
||||
try:
|
||||
await self._client.power_off()
|
||||
|
@ -325,9 +319,6 @@ class HarmonyRemote(remote.RemoteDevice):
|
|||
# pylint: disable=arguments-differ
|
||||
async def async_send_command(self, command, **kwargs):
|
||||
"""Send a list of commands to one device."""
|
||||
from aioharmony.harmonyapi import SendCommandDevice
|
||||
import aioharmony.exceptions as aioexc
|
||||
|
||||
_LOGGER.debug("%s: Send Command", self.name)
|
||||
device = kwargs.get(ATTR_DEVICE)
|
||||
if device is None:
|
||||
|
@ -390,8 +381,6 @@ class HarmonyRemote(remote.RemoteDevice):
|
|||
|
||||
async def change_channel(self, channel):
|
||||
"""Change the channel using Harmony remote."""
|
||||
import aioharmony.exceptions as aioexc
|
||||
|
||||
_LOGGER.debug("%s: Changing channel to %s", self.name, channel)
|
||||
try:
|
||||
await self._client.change_channel(channel)
|
||||
|
@ -400,8 +389,6 @@ class HarmonyRemote(remote.RemoteDevice):
|
|||
|
||||
async def sync(self):
|
||||
"""Sync the Harmony device with the web service."""
|
||||
import aioharmony.exceptions as aioexc
|
||||
|
||||
_LOGGER.debug("%s: Syncing hub with Harmony cloud", self.name)
|
||||
try:
|
||||
await self._client.sync()
|
||||
|
|
Loading…
Reference in New Issue