From 6c739f4be5913ba46c25527c5883f6945716526c Mon Sep 17 00:00:00 2001 From: Quentame Date: Thu, 10 Oct 2019 09:21:40 +0200 Subject: [PATCH] Move imports in nissan_leaf component (#27359) --- homeassistant/components/nissan_leaf/__init__.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/nissan_leaf/__init__.py b/homeassistant/components/nissan_leaf/__init__.py index 38b7018af6c..0c72f4f43ea 100644 --- a/homeassistant/components/nissan_leaf/__init__.py +++ b/homeassistant/components/nissan_leaf/__init__.py @@ -3,7 +3,7 @@ from datetime import datetime, timedelta import asyncio import logging import sys - +from pycarwings2 import CarwingsError, Session import voluptuous as vol from homeassistant.const import CONF_PASSWORD, CONF_USERNAME @@ -95,7 +95,6 @@ START_CHARGE_LEAF_SCHEMA = vol.Schema({vol.Required(ATTR_VIN): cv.string}) def setup(hass, config): """Set up the Nissan Leaf component.""" - import pycarwings2 async def async_handle_update(service): """Handle service to update leaf data from Nissan servers.""" @@ -148,7 +147,7 @@ def setup(hass, config): try: # This might need to be made async (somehow) causes # homeassistant to be slow to start - sess = pycarwings2.Session(username, password, region) + sess = Session(username, password, region) leaf = sess.get_leaf() except KeyError: _LOGGER.error( @@ -156,7 +155,7 @@ def setup(hass, config): " do you actually have a Leaf connected to your account?" ) return False - except pycarwings2.CarwingsError: + except CarwingsError: _LOGGER.error( "An unknown error occurred while connecting to Nissan: %s", sys.exc_info()[0], @@ -274,7 +273,6 @@ class LeafDataStore: async def async_refresh_data(self, now): """Refresh the leaf data and update the datastore.""" - from pycarwings2 import CarwingsError if self.request_in_progress: _LOGGER.debug("Refresh currently in progress for %s", self.leaf.nickname) @@ -339,7 +337,6 @@ class LeafDataStore: async def async_get_battery(self): """Request battery update from Nissan servers.""" - from pycarwings2 import CarwingsError try: # Request battery update from the car @@ -389,7 +386,6 @@ class LeafDataStore: async def async_get_climate(self): """Request climate data from Nissan servers.""" - from pycarwings2 import CarwingsError try: return await self.hass.async_add_executor_job(