mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00: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
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/sensor.ebox/
|
https://home-assistant.io/components/sensor.ebox/
|
||||||
"""
|
"""
|
||||||
import logging
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from pyebox import EboxClient
|
||||||
|
from pyebox.client import PyEboxError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
|
||||||
CONF_PASSWORD,
|
|
||||||
CONF_NAME,
|
|
||||||
CONF_MONITORED_VARIABLES,
|
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.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
|
||||||
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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)
|
name = config.get(CONF_NAME)
|
||||||
|
|
||||||
from pyebox.client import PyEboxError
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await ebox_data.async_update()
|
await ebox_data.async_update()
|
||||||
except PyEboxError as exp:
|
except PyEboxError as exp:
|
||||||
@ -135,16 +134,12 @@ class EBoxData:
|
|||||||
|
|
||||||
def __init__(self, username, password, httpsession):
|
def __init__(self, username, password, httpsession):
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
from pyebox import EboxClient
|
|
||||||
|
|
||||||
self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession)
|
self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession)
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Get the latest data from Ebox."""
|
"""Get the latest data from Ebox."""
|
||||||
from pyebox.client import PyEboxError
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.client.fetch_data()
|
await self.client.fetch_data()
|
||||||
except PyEboxError as exp:
|
except PyEboxError as exp:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user