Refactoring. Moved LCN constants to const.py (#21376)
This commit is contained in:
parent
b588c1fe1c
commit
fc13e37d8d
5 changed files with 40 additions and 33 deletions
|
@ -1,9 +1,12 @@
|
||||||
"""Support for LCN devices."""
|
"""Support for LCN devices."""
|
||||||
import logging
|
import logging
|
||||||
import re
|
|
||||||
|
|
||||||
import voluptuous as vol
|
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 (
|
from homeassistant.const import (
|
||||||
CONF_ADDRESS, CONF_COVERS, CONF_HOST, CONF_LIGHTS, CONF_NAME,
|
CONF_ADDRESS, CONF_COVERS, CONF_HOST, CONF_LIGHTS, CONF_NAME,
|
||||||
CONF_PASSWORD, CONF_PORT, CONF_SWITCHES, CONF_USERNAME)
|
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.discovery import async_load_platform
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['pypck==0.5.9']
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = 'lcn'
|
REQUIREMENTS = ['pypck==0.5.9']
|
||||||
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<conn_id>\\w+)\\.)?s?(?P<seg_id>\\d+)'
|
|
||||||
'\\.(?P<type>m|g)?(?P<id>\\d+)$')
|
|
||||||
|
|
||||||
|
|
||||||
def has_unique_connection_names(connections):
|
def has_unique_connection_names(connections):
|
||||||
|
|
26
homeassistant/components/lcn/const.py
Normal file
26
homeassistant/components/lcn/const.py
Normal file
|
@ -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<conn_id>\\w+)\\.)?s?(?P<seg_id>\\d+)'
|
||||||
|
'\\.(?P<type>m|g)?(?P<id>\\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']
|
|
@ -1,7 +1,8 @@
|
||||||
"""Support for LCN covers."""
|
"""Support for LCN covers."""
|
||||||
from homeassistant.components.cover import CoverDevice
|
from homeassistant.components.cover import CoverDevice
|
||||||
from homeassistant.components.lcn import (
|
from homeassistant.components.lcn import LcnDevice, get_connection
|
||||||
CONF_CONNECTIONS, CONF_MOTOR, DATA_LCN, LcnDevice, get_connection)
|
from homeassistant.components.lcn.const import (
|
||||||
|
CONF_CONNECTIONS, CONF_MOTOR, DATA_LCN)
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
|
|
||||||
DEPENDENCIES = ['lcn']
|
DEPENDENCIES = ['lcn']
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
"""Support for LCN lights."""
|
"""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,
|
CONF_CONNECTIONS, CONF_DIMMABLE, CONF_OUTPUT, CONF_TRANSITION, DATA_LCN,
|
||||||
OUTPUT_PORTS, LcnDevice, get_connection)
|
OUTPUT_PORTS)
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS, ATTR_TRANSITION, SUPPORT_BRIGHTNESS, SUPPORT_TRANSITION,
|
ATTR_BRIGHTNESS, ATTR_TRANSITION, SUPPORT_BRIGHTNESS, SUPPORT_TRANSITION,
|
||||||
Light)
|
Light)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for LCN switches."""
|
"""Support for LCN switches."""
|
||||||
from homeassistant.components.lcn import (
|
from homeassistant.components.lcn import LcnDevice, get_connection
|
||||||
CONF_CONNECTIONS, CONF_OUTPUT, DATA_LCN, OUTPUT_PORTS, LcnDevice,
|
from homeassistant.components.lcn.const import (
|
||||||
get_connection)
|
CONF_CONNECTIONS, CONF_OUTPUT, DATA_LCN, OUTPUT_PORTS)
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue