mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Move imports to top for tradfri (#29247)
This commit is contained in:
parent
93150f6f94
commit
9fbb345ce0
@ -1,32 +1,33 @@
|
|||||||
"""Support for IKEA Tradfri."""
|
"""Support for IKEA Tradfri."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
|
||||||
from pytradfri import Gateway, RequestError
|
from pytradfri import Gateway, RequestError
|
||||||
from pytradfri.api.aiocoap_api import APIFactory
|
from pytradfri.api.aiocoap_api import APIFactory
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util.json import load_json
|
from homeassistant.util.json import load_json
|
||||||
|
|
||||||
from . import config_flow # noqa: F401
|
from . import config_flow # noqa: F401
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
|
||||||
CONFIG_FILE,
|
|
||||||
KEY_GATEWAY,
|
|
||||||
KEY_API,
|
|
||||||
CONF_ALLOW_TRADFRI_GROUPS,
|
|
||||||
DEFAULT_ALLOW_TRADFRI_GROUPS,
|
|
||||||
TRADFRI_DEVICE_TYPES,
|
|
||||||
ATTR_TRADFRI_MANUFACTURER,
|
|
||||||
ATTR_TRADFRI_GATEWAY,
|
ATTR_TRADFRI_GATEWAY,
|
||||||
ATTR_TRADFRI_GATEWAY_MODEL,
|
ATTR_TRADFRI_GATEWAY_MODEL,
|
||||||
CONF_IMPORT_GROUPS,
|
ATTR_TRADFRI_MANUFACTURER,
|
||||||
CONF_IDENTITY,
|
CONF_ALLOW_TRADFRI_GROUPS,
|
||||||
CONF_HOST,
|
|
||||||
CONF_KEY,
|
|
||||||
CONF_GATEWAY_ID,
|
CONF_GATEWAY_ID,
|
||||||
|
CONF_HOST,
|
||||||
|
CONF_IDENTITY,
|
||||||
|
CONF_IMPORT_GROUPS,
|
||||||
|
CONF_KEY,
|
||||||
|
CONFIG_FILE,
|
||||||
|
DEFAULT_ALLOW_TRADFRI_GROUPS,
|
||||||
|
DOMAIN,
|
||||||
|
KEY_API,
|
||||||
|
KEY_GATEWAY,
|
||||||
|
TRADFRI_DEVICE_TYPES,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -5,6 +5,7 @@ from pytradfri.error import PytradfriError
|
|||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -4,15 +4,18 @@ from collections import OrderedDict
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
import async_timeout
|
import async_timeout
|
||||||
|
from pytradfri import Gateway, RequestError
|
||||||
|
from pytradfri.api.aiocoap_api import APIFactory
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_IMPORT_GROUPS,
|
|
||||||
CONF_IDENTITY,
|
|
||||||
CONF_HOST,
|
|
||||||
CONF_KEY,
|
|
||||||
CONF_GATEWAY_ID,
|
CONF_GATEWAY_ID,
|
||||||
|
CONF_HOST,
|
||||||
|
CONF_IDENTITY,
|
||||||
|
CONF_IMPORT_GROUPS,
|
||||||
|
CONF_KEY,
|
||||||
KEY_SECURITY_CODE,
|
KEY_SECURITY_CODE,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -153,8 +156,6 @@ class FlowHandler(config_entries.ConfigFlow):
|
|||||||
|
|
||||||
async def authenticate(hass, host, security_code):
|
async def authenticate(hass, host, security_code):
|
||||||
"""Authenticate with a Tradfri hub."""
|
"""Authenticate with a Tradfri hub."""
|
||||||
from pytradfri.api.aiocoap_api import APIFactory
|
|
||||||
from pytradfri import RequestError
|
|
||||||
|
|
||||||
identity = uuid4().hex
|
identity = uuid4().hex
|
||||||
|
|
||||||
@ -173,8 +174,6 @@ async def authenticate(hass, host, security_code):
|
|||||||
|
|
||||||
async def get_gateway_info(hass, host, identity, key):
|
async def get_gateway_info(hass, host, identity, key):
|
||||||
"""Return info for the gateway."""
|
"""Return info for the gateway."""
|
||||||
from pytradfri.api.aiocoap_api import APIFactory
|
|
||||||
from pytradfri import Gateway, RequestError
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
factory = APIFactory(host, psk_id=identity, psk=key, loop=hass.loop)
|
factory = APIFactory(host, psk_id=identity, psk=key, loop=hass.loop)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Consts used by Tradfri."""
|
"""Consts used by Tradfri."""
|
||||||
from homeassistant.components.light import SUPPORT_TRANSITION, SUPPORT_BRIGHTNESS
|
from homeassistant.components.light import SUPPORT_BRIGHTNESS, SUPPORT_TRANSITION
|
||||||
from homeassistant.const import CONF_HOST # noqa: F401 pylint: disable=unused-import
|
from homeassistant.const import CONF_HOST # noqa: F401 pylint: disable=unused-import
|
||||||
|
|
||||||
ATTR_DIMMER = "dimmer"
|
ATTR_DIMMER = "dimmer"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
"""Support for IKEA Tradfri covers."""
|
"""Support for IKEA Tradfri covers."""
|
||||||
|
|
||||||
from homeassistant.components.cover import CoverDevice, ATTR_POSITION
|
from homeassistant.components.cover import ATTR_POSITION, CoverDevice
|
||||||
|
|
||||||
from .base_class import TradfriBaseDevice
|
from .base_class import TradfriBaseDevice
|
||||||
from .const import KEY_GATEWAY, KEY_API, CONF_GATEWAY_ID
|
from .const import CONF_GATEWAY_ID, KEY_API, KEY_GATEWAY
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
|
@ -1,29 +1,30 @@
|
|||||||
"""Support for IKEA Tradfri lights."""
|
"""Support for IKEA Tradfri lights."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import homeassistant.util.color as color_util
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP,
|
ATTR_COLOR_TEMP,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
Light,
|
|
||||||
SUPPORT_BRIGHTNESS,
|
SUPPORT_BRIGHTNESS,
|
||||||
SUPPORT_COLOR,
|
SUPPORT_COLOR,
|
||||||
SUPPORT_COLOR_TEMP,
|
SUPPORT_COLOR_TEMP,
|
||||||
|
Light,
|
||||||
)
|
)
|
||||||
from .base_class import TradfriBaseDevice, TradfriBaseClass
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
|
from .base_class import TradfriBaseClass, TradfriBaseDevice
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_DIMMER,
|
ATTR_DIMMER,
|
||||||
ATTR_HUE,
|
ATTR_HUE,
|
||||||
ATTR_SAT,
|
ATTR_SAT,
|
||||||
ATTR_TRANSITION_TIME,
|
ATTR_TRANSITION_TIME,
|
||||||
SUPPORTED_LIGHT_FEATURES,
|
|
||||||
SUPPORTED_GROUP_FEATURES,
|
|
||||||
CONF_GATEWAY_ID,
|
CONF_GATEWAY_ID,
|
||||||
CONF_IMPORT_GROUPS,
|
CONF_IMPORT_GROUPS,
|
||||||
KEY_GATEWAY,
|
|
||||||
KEY_API,
|
KEY_API,
|
||||||
|
KEY_GATEWAY,
|
||||||
|
SUPPORTED_GROUP_FEATURES,
|
||||||
|
SUPPORTED_LIGHT_FEATURES,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
"""Support for IKEA Tradfri sensors."""
|
"""Support for IKEA Tradfri sensors."""
|
||||||
|
|
||||||
from homeassistant.const import DEVICE_CLASS_BATTERY
|
from homeassistant.const import DEVICE_CLASS_BATTERY
|
||||||
|
|
||||||
from .base_class import TradfriBaseDevice
|
from .base_class import TradfriBaseDevice
|
||||||
from .const import KEY_GATEWAY, KEY_API, CONF_GATEWAY_ID
|
from .const import CONF_GATEWAY_ID, KEY_API, KEY_GATEWAY
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
"""Support for IKEA Tradfri switches."""
|
"""Support for IKEA Tradfri switches."""
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
|
|
||||||
from .base_class import TradfriBaseDevice
|
from .base_class import TradfriBaseDevice
|
||||||
from .const import KEY_GATEWAY, KEY_API, CONF_GATEWAY_ID
|
from .const import CONF_GATEWAY_ID, KEY_API, KEY_GATEWAY
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user