Move imports to top for sense (#29258)

This commit is contained in:
springstan 2019-12-01 06:35:45 +01:00 committed by Paulus Schoutsen
parent 2bdf7fc8f5
commit c4c8a1ba2d
3 changed files with 9 additions and 8 deletions

View file

@ -1,7 +1,12 @@
"""Support for monitoring a Sense energy sensor.""" """Support for monitoring a Sense energy sensor."""
import logging
from datetime import timedelta from datetime import timedelta
import logging
from sense_energy import (
ASyncSenseable,
SenseAPITimeoutException,
SenseAuthenticationException,
)
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_TIMEOUT from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_TIMEOUT
@ -36,11 +41,6 @@ CONFIG_SCHEMA = vol.Schema(
async def async_setup(hass, config): async def async_setup(hass, config):
"""Set up the Sense sensor.""" """Set up the Sense sensor."""
from sense_energy import (
ASyncSenseable,
SenseAuthenticationException,
SenseAPITimeoutException,
)
username = config[DOMAIN][CONF_EMAIL] username = config[DOMAIN][CONF_EMAIL]
password = config[DOMAIN][CONF_PASSWORD] password = config[DOMAIN][CONF_PASSWORD]

View file

@ -2,8 +2,8 @@
import logging import logging
from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from . import SENSE_DATA, SENSE_DEVICE_UPDATE from . import SENSE_DATA, SENSE_DEVICE_UPDATE

View file

@ -2,6 +2,8 @@
from datetime import timedelta from datetime import timedelta
import logging import logging
from sense_energy import SenseAPITimeoutException
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
@ -114,7 +116,6 @@ class Sense(Entity):
async def async_update(self): async def async_update(self):
"""Get the latest data, update state.""" """Get the latest data, update state."""
from sense_energy import SenseAPITimeoutException
try: try:
await self.update_sensor() await self.update_sensor()