diff --git a/homeassistant/components/lcn/__init__.py b/homeassistant/components/lcn/__init__.py index 2f8f9fb4e1c..c7c180737f0 100644 --- a/homeassistant/components/lcn/__init__.py +++ b/homeassistant/components/lcn/__init__.py @@ -1,9 +1,12 @@ """Support for LCN devices.""" import logging -import re import voluptuous as vol +from homeassistant.components.lcn.const import ( + CONF_CONNECTIONS, CONF_DIM_MODE, CONF_DIMMABLE, CONF_MOTOR, CONF_OUTPUT, + CONF_SK_NUM_TRIES, CONF_TRANSITION, DATA_LCN, DEFAULT_NAME, DIM_MODES, + DOMAIN, MOTOR_PORTS, OUTPUT_PORTS, PATTERN_ADDRESS, RELAY_PORTS) from homeassistant.const import ( CONF_ADDRESS, CONF_COVERS, CONF_HOST, CONF_LIGHTS, CONF_NAME, CONF_PASSWORD, CONF_PORT, CONF_SWITCHES, CONF_USERNAME) @@ -11,33 +14,9 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.discovery import async_load_platform from homeassistant.helpers.entity import Entity -REQUIREMENTS = ['pypck==0.5.9'] - _LOGGER = logging.getLogger(__name__) -DOMAIN = 'lcn' -DATA_LCN = 'lcn' -DEFAULT_NAME = 'pchk' - -CONF_SK_NUM_TRIES = 'sk_num_tries' -CONF_DIM_MODE = 'dim_mode' -CONF_OUTPUT = 'output' -CONF_TRANSITION = 'transition' -CONF_DIMMABLE = 'dimmable' -CONF_CONNECTIONS = 'connections' -CONF_MOTOR = 'motor' - -DIM_MODES = ['STEPS50', 'STEPS200'] -OUTPUT_PORTS = ['OUTPUT1', 'OUTPUT2', 'OUTPUT3', 'OUTPUT4'] -RELAY_PORTS = ['RELAY1', 'RELAY2', 'RELAY3', 'RELAY4', - 'RELAY5', 'RELAY6', 'RELAY7', 'RELAY8', - 'MOTORONOFF1', 'MOTORUPDOWN1', 'MOTORONOFF2', 'MOTORUPDOWN2', - 'MOTORONOFF3', 'MOTORUPDOWN3', 'MOTORONOFF4', 'MOTORUPDOWN4'] -MOTOR_PORTS = ['MOTOR1', 'MOTOR2', 'MOTOR3', 'MOTOR4'] - -# Regex for address validation -PATTERN_ADDRESS = re.compile('^((?P\\w+)\\.)?s?(?P\\d+)' - '\\.(?Pm|g)?(?P\\d+)$') +REQUIREMENTS = ['pypck==0.5.9'] def has_unique_connection_names(connections): diff --git a/homeassistant/components/lcn/const.py b/homeassistant/components/lcn/const.py new file mode 100644 index 00000000000..02b35b06797 --- /dev/null +++ b/homeassistant/components/lcn/const.py @@ -0,0 +1,26 @@ +"""Constants for the LCN component.""" +import re + +DOMAIN = 'lcn' +DATA_LCN = 'lcn' +DEFAULT_NAME = 'pchk' + +# Regex for address validation +PATTERN_ADDRESS = re.compile('^((?P\\w+)\\.)?s?(?P\\d+)' + '\\.(?Pm|g)?(?P\\d+)$') + +CONF_CONNECTIONS = 'connections' +CONF_SK_NUM_TRIES = 'sk_num_tries' +CONF_OUTPUT = 'output' +CONF_DIM_MODE = 'dim_mode' +CONF_DIMMABLE = 'dimmable' +CONF_TRANSITION = 'transition' +CONF_MOTOR = 'motor' + +DIM_MODES = ['STEPS50', 'STEPS200'] +OUTPUT_PORTS = ['OUTPUT1', 'OUTPUT2', 'OUTPUT3', 'OUTPUT4'] +RELAY_PORTS = ['RELAY1', 'RELAY2', 'RELAY3', 'RELAY4', + 'RELAY5', 'RELAY6', 'RELAY7', 'RELAY8', + 'MOTORONOFF1', 'MOTORUPDOWN1', 'MOTORONOFF2', 'MOTORUPDOWN2', + 'MOTORONOFF3', 'MOTORUPDOWN3', 'MOTORONOFF4', 'MOTORUPDOWN4'] +MOTOR_PORTS = ['MOTOR1', 'MOTOR2', 'MOTOR3', 'MOTOR4'] diff --git a/homeassistant/components/lcn/cover.py b/homeassistant/components/lcn/cover.py index 8151144f077..4b4542fd623 100755 --- a/homeassistant/components/lcn/cover.py +++ b/homeassistant/components/lcn/cover.py @@ -1,7 +1,8 @@ """Support for LCN covers.""" from homeassistant.components.cover import CoverDevice -from homeassistant.components.lcn import ( - CONF_CONNECTIONS, CONF_MOTOR, DATA_LCN, LcnDevice, get_connection) +from homeassistant.components.lcn import LcnDevice, get_connection +from homeassistant.components.lcn.const import ( + CONF_CONNECTIONS, CONF_MOTOR, DATA_LCN) from homeassistant.const import CONF_ADDRESS DEPENDENCIES = ['lcn'] diff --git a/homeassistant/components/lcn/light.py b/homeassistant/components/lcn/light.py index 2b7f4ed4074..5f1008cbd57 100644 --- a/homeassistant/components/lcn/light.py +++ b/homeassistant/components/lcn/light.py @@ -1,7 +1,8 @@ """Support for LCN lights.""" -from homeassistant.components.lcn import ( +from homeassistant.components.lcn import LcnDevice, get_connection +from homeassistant.components.lcn.const import ( CONF_CONNECTIONS, CONF_DIMMABLE, CONF_OUTPUT, CONF_TRANSITION, DATA_LCN, - OUTPUT_PORTS, LcnDevice, get_connection) + OUTPUT_PORTS) from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_TRANSITION, SUPPORT_BRIGHTNESS, SUPPORT_TRANSITION, Light) diff --git a/homeassistant/components/lcn/switch.py b/homeassistant/components/lcn/switch.py index 60eda2ea779..09f35d26718 100755 --- a/homeassistant/components/lcn/switch.py +++ b/homeassistant/components/lcn/switch.py @@ -1,7 +1,7 @@ """Support for LCN switches.""" -from homeassistant.components.lcn import ( - CONF_CONNECTIONS, CONF_OUTPUT, DATA_LCN, OUTPUT_PORTS, LcnDevice, - get_connection) +from homeassistant.components.lcn import LcnDevice, get_connection +from homeassistant.components.lcn.const import ( + CONF_CONNECTIONS, CONF_OUTPUT, DATA_LCN, OUTPUT_PORTS) from homeassistant.components.switch import SwitchDevice from homeassistant.const import CONF_ADDRESS