diff --git a/homeassistant/components/switch/__init__.py b/homeassistant/components/switch/__init__.py index 26d5658d668..78c57e001aa 100644 --- a/homeassistant/components/switch/__init__.py +++ b/homeassistant/components/switch/__init__.py @@ -4,21 +4,20 @@ import logging import voluptuous as vol -from homeassistant.loader import bind_hass -from homeassistant.helpers.entity_component import EntityComponent -from homeassistant.helpers.entity import ToggleEntity +from homeassistant.components import group +from homeassistant.const import ( + SERVICE_TOGGLE, + SERVICE_TURN_OFF, + SERVICE_TURN_ON, + STATE_ON, +) from homeassistant.helpers.config_validation import ( # noqa: F401 PLATFORM_SCHEMA, PLATFORM_SCHEMA_BASE, ) -from homeassistant.const import ( - STATE_ON, - SERVICE_TURN_ON, - SERVICE_TURN_OFF, - SERVICE_TOGGLE, -) -from homeassistant.components import group - +from homeassistant.helpers.entity import ToggleEntity +from homeassistant.helpers.entity_component import EntityComponent +from homeassistant.loader import bind_hass # mypy: allow-untyped-defs, no-check-untyped-defs diff --git a/homeassistant/components/switch/device_action.py b/homeassistant/components/switch/device_action.py index a65c1acc512..a50131f094c 100644 --- a/homeassistant/components/switch/device_action.py +++ b/homeassistant/components/switch/device_action.py @@ -1,13 +1,14 @@ """Provides device actions for switches.""" from typing import List + import voluptuous as vol -from homeassistant.core import HomeAssistant, Context from homeassistant.components.device_automation import toggle_entity from homeassistant.const import CONF_DOMAIN -from homeassistant.helpers.typing import TemplateVarsType, ConfigType -from . import DOMAIN +from homeassistant.core import Context, HomeAssistant +from homeassistant.helpers.typing import ConfigType, TemplateVarsType +from . import DOMAIN ACTION_SCHEMA = toggle_entity.ACTION_SCHEMA.extend({vol.Required(CONF_DOMAIN): DOMAIN}) diff --git a/homeassistant/components/switch/device_condition.py b/homeassistant/components/switch/device_condition.py index 56f8f6c196e..87aefdb616d 100644 --- a/homeassistant/components/switch/device_condition.py +++ b/homeassistant/components/switch/device_condition.py @@ -1,14 +1,15 @@ """Provides device conditions for switches.""" from typing import Dict, List + import voluptuous as vol -from homeassistant.core import HomeAssistant from homeassistant.components.device_automation import toggle_entity from homeassistant.const import CONF_DOMAIN -from homeassistant.helpers.typing import ConfigType +from homeassistant.core import HomeAssistant from homeassistant.helpers.condition import ConditionCheckerType -from . import DOMAIN +from homeassistant.helpers.typing import ConfigType +from . import DOMAIN CONDITION_SCHEMA = toggle_entity.CONDITION_SCHEMA.extend( {vol.Required(CONF_DOMAIN): DOMAIN} diff --git a/homeassistant/components/switch/device_trigger.py b/homeassistant/components/switch/device_trigger.py index 7f0458b3e9f..cb5d5f7aa0e 100644 --- a/homeassistant/components/switch/device_trigger.py +++ b/homeassistant/components/switch/device_trigger.py @@ -1,14 +1,15 @@ """Provides device triggers for switches.""" from typing import List + import voluptuous as vol -from homeassistant.core import HomeAssistant, CALLBACK_TYPE from homeassistant.components.automation import AutomationActionType from homeassistant.components.device_automation import toggle_entity from homeassistant.const import CONF_DOMAIN +from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.helpers.typing import ConfigType -from . import DOMAIN +from . import DOMAIN TRIGGER_SCHEMA = toggle_entity.TRIGGER_SCHEMA.extend( {vol.Required(CONF_DOMAIN): DOMAIN} diff --git a/homeassistant/components/switch/light.py b/homeassistant/components/switch/light.py index 1bdc1d39083..5486b8d880c 100644 --- a/homeassistant/components/switch/light.py +++ b/homeassistant/components/switch/light.py @@ -1,10 +1,11 @@ """Light support for switch entities.""" import logging -from typing import cast, Callable, Dict, Optional, Sequence +from typing import Callable, Dict, Optional, Sequence, cast import voluptuous as vol from homeassistant.components import switch +from homeassistant.components.light import PLATFORM_SCHEMA, Light from homeassistant.const import ( ATTR_ENTITY_ID, CONF_ENTITY_ID, @@ -18,9 +19,6 @@ from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_state_change from homeassistant.helpers.typing import ConfigType, HomeAssistantType -from homeassistant.components.light import PLATFORM_SCHEMA, Light - - # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/switch/reproduce_state.py b/homeassistant/components/switch/reproduce_state.py index 7ed1f70cb97..d2bfc569956 100644 --- a/homeassistant/components/switch/reproduce_state.py +++ b/homeassistant/components/switch/reproduce_state.py @@ -5,10 +5,10 @@ from typing import Iterable, Optional from homeassistant.const import ( ATTR_ENTITY_ID, - STATE_ON, - STATE_OFF, SERVICE_TURN_OFF, SERVICE_TURN_ON, + STATE_OFF, + STATE_ON, ) from homeassistant.core import Context, State from homeassistant.helpers.typing import HomeAssistantType diff --git a/tests/components/switch/common.py b/tests/components/switch/common.py index 2c6b1ccd0d2..1123b1de6c1 100644 --- a/tests/components/switch/common.py +++ b/tests/components/switch/common.py @@ -6,9 +6,9 @@ components. Instead call the service directly. from homeassistant.components.switch import DOMAIN from homeassistant.const import ( ATTR_ENTITY_ID, + ENTITY_MATCH_ALL, SERVICE_TURN_OFF, SERVICE_TURN_ON, - ENTITY_MATCH_ALL, ) from homeassistant.loader import bind_hass diff --git a/tests/components/switch/test_device_action.py b/tests/components/switch/test_device_action.py index 888e06e0214..06ad7323ead 100644 --- a/tests/components/switch/test_device_action.py +++ b/tests/components/switch/test_device_action.py @@ -1,14 +1,14 @@ """The test for switch device automation.""" import pytest -from homeassistant.components.switch import DOMAIN -from homeassistant.const import STATE_ON, STATE_OFF, CONF_PLATFORM -from homeassistant.setup import async_setup_component import homeassistant.components.automation as automation from homeassistant.components.device_automation import ( _async_get_device_automations as async_get_device_automations, ) +from homeassistant.components.switch import DOMAIN +from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON from homeassistant.helpers import device_registry +from homeassistant.setup import async_setup_component from tests.common import ( MockConfigEntry, diff --git a/tests/components/switch/test_device_condition.py b/tests/components/switch/test_device_condition.py index e673527fada..d51a00ddf79 100644 --- a/tests/components/switch/test_device_condition.py +++ b/tests/components/switch/test_device_condition.py @@ -1,22 +1,23 @@ """The test for switch device automation.""" from datetime import timedelta -import pytest from unittest.mock import patch -from homeassistant.components.switch import DOMAIN -from homeassistant.const import STATE_ON, STATE_OFF, CONF_PLATFORM -from homeassistant.setup import async_setup_component +import pytest + import homeassistant.components.automation as automation +from homeassistant.components.switch import DOMAIN +from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON from homeassistant.helpers import device_registry +from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util from tests.common import ( MockConfigEntry, + async_get_device_automation_capabilities, + async_get_device_automations, async_mock_service, mock_device_registry, mock_registry, - async_get_device_automations, - async_get_device_automation_capabilities, ) diff --git a/tests/components/switch/test_device_trigger.py b/tests/components/switch/test_device_trigger.py index 31fb6d30f60..19588ebfba0 100644 --- a/tests/components/switch/test_device_trigger.py +++ b/tests/components/switch/test_device_trigger.py @@ -1,22 +1,23 @@ """The test for switch device automation.""" from datetime import timedelta + import pytest -from homeassistant.components.switch import DOMAIN -from homeassistant.const import STATE_ON, STATE_OFF, CONF_PLATFORM -from homeassistant.setup import async_setup_component import homeassistant.components.automation as automation +from homeassistant.components.switch import DOMAIN +from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON from homeassistant.helpers import device_registry +from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util from tests.common import ( MockConfigEntry, async_fire_time_changed, + async_get_device_automation_capabilities, + async_get_device_automations, async_mock_service, mock_device_registry, mock_registry, - async_get_device_automations, - async_get_device_automation_capabilities, ) diff --git a/tests/components/switch/test_init.py b/tests/components/switch/test_init.py index a9463cb78f4..bebebafc763 100644 --- a/tests/components/switch/test_init.py +++ b/tests/components/switch/test_init.py @@ -2,10 +2,10 @@ # pylint: disable=protected-access import unittest -from homeassistant.setup import setup_component, async_setup_component from homeassistant import core from homeassistant.components import switch -from homeassistant.const import STATE_ON, STATE_OFF, CONF_PLATFORM +from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON +from homeassistant.setup import async_setup_component, setup_component from tests.common import get_test_home_assistant, mock_entity_platform from tests.components.switch import common diff --git a/tests/components/switch/test_light.py b/tests/components/switch/test_light.py index e5c5e5c0aed..3034877c6d6 100644 --- a/tests/components/switch/test_light.py +++ b/tests/components/switch/test_light.py @@ -1,6 +1,7 @@ """The tests for the Light Switch platform.""" from homeassistant.setup import async_setup_component + from tests.components.light import common from tests.components.switch import common as switch_common