mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
move imports in sma component (#27945)
This commit is contained in:
parent
5ce437dc30
commit
5a592f1291
@ -3,17 +3,18 @@ import asyncio
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import pysma
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
|
CONF_PATH,
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
CONF_SSL,
|
CONF_SSL,
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
CONF_PATH,
|
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -35,8 +36,6 @@ GROUPS = ["user", "installer"]
|
|||||||
def _check_sensor_schema(conf):
|
def _check_sensor_schema(conf):
|
||||||
"""Check sensors and attributes are valid."""
|
"""Check sensors and attributes are valid."""
|
||||||
try:
|
try:
|
||||||
import pysma
|
|
||||||
|
|
||||||
valid = [s.name for s in pysma.Sensors()]
|
valid = [s.name for s in pysma.Sensors()]
|
||||||
except (ImportError, AttributeError):
|
except (ImportError, AttributeError):
|
||||||
return conf
|
return conf
|
||||||
@ -87,7 +86,6 @@ PLATFORM_SCHEMA = vol.All(
|
|||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||||
"""Set up SMA WebConnect sensor."""
|
"""Set up SMA WebConnect sensor."""
|
||||||
import pysma
|
|
||||||
|
|
||||||
# Check config again during load - dependency available
|
# Check config again during load - dependency available
|
||||||
config = _check_sensor_schema(config)
|
config = _check_sensor_schema(config)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user