mirror of
https://github.com/home-assistant/core
synced 2024-08-06 09:34:49 +02:00
Move ebox imports at top-level (#29048)
This commit is contained in:
parent
63f66785ad
commit
cb5d00a07b
@ -6,23 +6,24 @@ Get data from 'My Usage Page' page: https://client.ebox.ca/myusage
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.ebox/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from pyebox import EboxClient
|
||||
from pyebox.client import PyEboxError
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_NAME,
|
||||
CONF_MONITORED_VARIABLES,
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -75,8 +76,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||
|
||||
name = config.get(CONF_NAME)
|
||||
|
||||
from pyebox.client import PyEboxError
|
||||
|
||||
try:
|
||||
await ebox_data.async_update()
|
||||
except PyEboxError as exp:
|
||||
@ -135,16 +134,12 @@ class EBoxData:
|
||||
|
||||
def __init__(self, username, password, httpsession):
|
||||
"""Initialize the data object."""
|
||||
from pyebox import EboxClient
|
||||
|
||||
self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession)
|
||||
self.data = {}
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
async def async_update(self):
|
||||
"""Get the latest data from Ebox."""
|
||||
from pyebox.client import PyEboxError
|
||||
|
||||
try:
|
||||
await self.client.fetch_data()
|
||||
except PyEboxError as exp:
|
||||
|
Loading…
Reference in New Issue
Block a user