mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Move imports to top for scsgate (#29257)
This commit is contained in:
parent
1560d84cd7
commit
bb46918d2e
@ -2,6 +2,10 @@
|
|||||||
import logging
|
import logging
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
|
from scsgate.connection import Connection
|
||||||
|
from scsgate.messages import ScenarioTriggeredMessage, StateMessage
|
||||||
|
from scsgate.reactor import Reactor
|
||||||
|
from scsgate.tasks import GetStatusTask
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_DEVICE, CONF_NAME
|
from homeassistant.const import CONF_DEVICE, CONF_NAME
|
||||||
@ -61,12 +65,8 @@ class SCSGate:
|
|||||||
self._device_being_registered = None
|
self._device_being_registered = None
|
||||||
self._device_being_registered_lock = Lock()
|
self._device_being_registered_lock = Lock()
|
||||||
|
|
||||||
from scsgate.connection import Connection
|
|
||||||
|
|
||||||
connection = Connection(device=device, logger=self._logger)
|
connection = Connection(device=device, logger=self._logger)
|
||||||
|
|
||||||
from scsgate.reactor import Reactor
|
|
||||||
|
|
||||||
self._reactor = Reactor(
|
self._reactor = Reactor(
|
||||||
connection=connection,
|
connection=connection,
|
||||||
logger=self._logger,
|
logger=self._logger,
|
||||||
@ -75,7 +75,6 @@ class SCSGate:
|
|||||||
|
|
||||||
def handle_message(self, message):
|
def handle_message(self, message):
|
||||||
"""Handle a messages seen on the bus."""
|
"""Handle a messages seen on the bus."""
|
||||||
from scsgate.messages import StateMessage, ScenarioTriggeredMessage
|
|
||||||
|
|
||||||
self._logger.debug(f"Received message {message}")
|
self._logger.debug(f"Received message {message}")
|
||||||
if not isinstance(message, StateMessage) and not isinstance(
|
if not isinstance(message, StateMessage) and not isinstance(
|
||||||
@ -132,7 +131,6 @@ class SCSGate:
|
|||||||
|
|
||||||
def _activate_next_device(self):
|
def _activate_next_device(self):
|
||||||
"""Start the activation of the first device."""
|
"""Start the activation of the first device."""
|
||||||
from scsgate.tasks import GetStatusTask
|
|
||||||
|
|
||||||
with self._devices_to_register_lock:
|
with self._devices_to_register_lock:
|
||||||
while self._devices_to_register:
|
while self._devices_to_register:
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
"""Support for SCSGate covers."""
|
"""Support for SCSGate covers."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from scsgate.tasks import (
|
||||||
|
HaltRollerShutterTask,
|
||||||
|
LowerRollerShutterTask,
|
||||||
|
RaiseRollerShutterTask,
|
||||||
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import scsgate
|
from homeassistant.components import scsgate
|
||||||
from homeassistant.components.cover import CoverDevice, PLATFORM_SCHEMA
|
from homeassistant.components.cover import PLATFORM_SCHEMA, CoverDevice
|
||||||
from homeassistant.const import CONF_DEVICES, CONF_NAME
|
from homeassistant.const import CONF_DEVICES, CONF_NAME
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
@ -69,20 +74,14 @@ class SCSGateCover(CoverDevice):
|
|||||||
|
|
||||||
def open_cover(self, **kwargs):
|
def open_cover(self, **kwargs):
|
||||||
"""Move the cover."""
|
"""Move the cover."""
|
||||||
from scsgate.tasks import RaiseRollerShutterTask
|
|
||||||
|
|
||||||
scsgate.SCSGATE.append_task(RaiseRollerShutterTask(target=self._scs_id))
|
scsgate.SCSGATE.append_task(RaiseRollerShutterTask(target=self._scs_id))
|
||||||
|
|
||||||
def close_cover(self, **kwargs):
|
def close_cover(self, **kwargs):
|
||||||
"""Move the cover down."""
|
"""Move the cover down."""
|
||||||
from scsgate.tasks import LowerRollerShutterTask
|
|
||||||
|
|
||||||
scsgate.SCSGATE.append_task(LowerRollerShutterTask(target=self._scs_id))
|
scsgate.SCSGATE.append_task(LowerRollerShutterTask(target=self._scs_id))
|
||||||
|
|
||||||
def stop_cover(self, **kwargs):
|
def stop_cover(self, **kwargs):
|
||||||
"""Stop the cover."""
|
"""Stop the cover."""
|
||||||
from scsgate.tasks import HaltRollerShutterTask
|
|
||||||
|
|
||||||
scsgate.SCSGATE.append_task(HaltRollerShutterTask(target=self._scs_id))
|
scsgate.SCSGATE.append_task(HaltRollerShutterTask(target=self._scs_id))
|
||||||
|
|
||||||
def process_event(self, message):
|
def process_event(self, message):
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
"""Support for SCSGate lights."""
|
"""Support for SCSGate lights."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from scsgate.tasks import ToggleStatusTask
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import scsgate
|
from homeassistant.components import scsgate
|
||||||
from homeassistant.components.light import Light, PLATFORM_SCHEMA
|
from homeassistant.components.light import PLATFORM_SCHEMA, Light
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME
|
from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
@ -70,7 +71,6 @@ class SCSGateLight(Light):
|
|||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
from scsgate.tasks import ToggleStatusTask
|
|
||||||
|
|
||||||
scsgate.SCSGATE.append_task(ToggleStatusTask(target=self._scs_id, toggled=True))
|
scsgate.SCSGATE.append_task(ToggleStatusTask(target=self._scs_id, toggled=True))
|
||||||
|
|
||||||
@ -79,7 +79,6 @@ class SCSGateLight(Light):
|
|||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
from scsgate.tasks import ToggleStatusTask
|
|
||||||
|
|
||||||
scsgate.SCSGATE.append_task(
|
scsgate.SCSGATE.append_task(
|
||||||
ToggleStatusTask(target=self._scs_id, toggled=False)
|
ToggleStatusTask(target=self._scs_id, toggled=False)
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
"""Support for SCSGate switches."""
|
"""Support for SCSGate switches."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from scsgate.messages import ScenarioTriggeredMessage, StateMessage
|
||||||
|
from scsgate.tasks import ToggleStatusTask
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import scsgate
|
from homeassistant.components import scsgate
|
||||||
from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA
|
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_NAME, CONF_DEVICES
|
from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
ATTR_SCENARIO_ID = "scenario_id"
|
ATTR_SCENARIO_ID = "scenario_id"
|
||||||
@ -105,7 +107,6 @@ class SCSGateSwitch(SwitchDevice):
|
|||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
from scsgate.tasks import ToggleStatusTask
|
|
||||||
|
|
||||||
scsgate.SCSGATE.append_task(ToggleStatusTask(target=self._scs_id, toggled=True))
|
scsgate.SCSGATE.append_task(ToggleStatusTask(target=self._scs_id, toggled=True))
|
||||||
|
|
||||||
@ -114,7 +115,6 @@ class SCSGateSwitch(SwitchDevice):
|
|||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
from scsgate.tasks import ToggleStatusTask
|
|
||||||
|
|
||||||
scsgate.SCSGATE.append_task(
|
scsgate.SCSGATE.append_task(
|
||||||
ToggleStatusTask(target=self._scs_id, toggled=False)
|
ToggleStatusTask(target=self._scs_id, toggled=False)
|
||||||
@ -172,7 +172,6 @@ class SCSGateScenarioSwitch:
|
|||||||
|
|
||||||
def process_event(self, message):
|
def process_event(self, message):
|
||||||
"""Handle a SCSGate message related with this switch."""
|
"""Handle a SCSGate message related with this switch."""
|
||||||
from scsgate.messages import StateMessage, ScenarioTriggeredMessage
|
|
||||||
|
|
||||||
if isinstance(message, StateMessage):
|
if isinstance(message, StateMessage):
|
||||||
scenario_id = message.bytes[4]
|
scenario_id = message.bytes[4]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user