Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move constant to 'const.py' and use already definied ones #10204

Merged
merged 1 commit into from Oct 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions homeassistant/components/climate/honeywell.py
Expand Up @@ -11,16 +11,15 @@
import requests
import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.climate import (
ClimateDevice, PLATFORM_SCHEMA, ATTR_FAN_MODE, ATTR_FAN_LIST,
ATTR_OPERATION_MODE, ATTR_OPERATION_LIST)
from homeassistant.const import (
CONF_PASSWORD, CONF_USERNAME, TEMP_CELSIUS, TEMP_FAHRENHEIT,
ATTR_TEMPERATURE)
import homeassistant.helpers.config_validation as cv
ATTR_TEMPERATURE, CONF_REGION)

REQUIREMENTS = ['evohomeclient==0.2.5',
'somecomfort==0.4.1']
REQUIREMENTS = ['evohomeclient==0.2.5', 'somecomfort==0.4.1']

_LOGGER = logging.getLogger(__name__)

Expand All @@ -31,7 +30,6 @@
CONF_AWAY_TEMPERATURE = 'away_temperature'
CONF_COOL_AWAY_TEMPERATURE = 'away_cool_temperature'
CONF_HEAT_AWAY_TEMPERATURE = 'away_heat_temperature'
CONF_REGION = 'region'

DEFAULT_AWAY_TEMPERATURE = 16
DEFAULT_COOL_AWAY_TEMPERATURE = 30
Expand Down
15 changes: 8 additions & 7 deletions homeassistant/components/cloud/__init__.py
Expand Up @@ -6,22 +6,23 @@

import voluptuous as vol

from homeassistant.const import EVENT_HOMEASSISTANT_START
from homeassistant.const import (
EVENT_HOMEASSISTANT_START, CONF_REGION, CONF_MODE)

from . import http_api, iot
from .const import CONFIG_DIR, DOMAIN, SERVERS


REQUIREMENTS = ['warrant==0.5.0']
DEPENDENCIES = ['http']
CONF_MODE = 'mode'

_LOGGER = logging.getLogger(__name__)

CONF_COGNITO_CLIENT_ID = 'cognito_client_id'
CONF_USER_POOL_ID = 'user_pool_id'
CONF_REGION = 'region'
CONF_RELAYER = 'relayer'
CONF_USER_POOL_ID = 'user_pool_id'

MODE_DEV = 'development'
DEFAULT_MODE = MODE_DEV
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['http']

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
Expand Down
28 changes: 11 additions & 17 deletions homeassistant/components/device_tracker/asuswrt.py
Expand Up @@ -12,18 +12,17 @@

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (
DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import (
CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT)
import homeassistant.helpers.config_validation as cv
CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT, CONF_MODE,
CONF_PROTOCOL)

REQUIREMENTS = ['pexpect==4.0.1']

_LOGGER = logging.getLogger(__name__)

CONF_MODE = 'mode'
CONF_PROTOCOL = 'protocol'
CONF_PUB_KEY = 'pub_key'
CONF_SSH_KEY = 'ssh_key'

Expand All @@ -36,10 +35,8 @@
PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_USERNAME): cv.string,
vol.Optional(CONF_PROTOCOL, default='ssh'):
vol.In(['ssh', 'telnet']),
vol.Optional(CONF_MODE, default='router'):
vol.In(['router', 'ap']),
vol.Optional(CONF_PROTOCOL, default='ssh'): vol.In(['ssh', 'telnet']),
vol.Optional(CONF_MODE, default='router'): vol.In(['router', 'ap']),
vol.Optional(CONF_PORT, default=DEFAULT_SSH_PORT): cv.port,
vol.Exclusive(CONF_PASSWORD, SECRET_GROUP): cv.string,
vol.Exclusive(CONF_SSH_KEY, SECRET_GROUP): cv.isfile,
Expand Down Expand Up @@ -102,21 +99,18 @@ def __init__(self, config):
self.success_init = False
return

self.connection = SshConnection(self.host, self.port,
self.username,
self.password,
self.ssh_key,
self.mode == "ap")
self.connection = SshConnection(
self.host, self.port, self.username, self.password,
self.ssh_key, self.mode == 'ap')
else:
if not self.password:
_LOGGER.error("No password specified")
self.success_init = False
return

self.connection = TelnetConnection(self.host, self.port,
self.username,
self.password,
self.mode == "ap")
self.connection = TelnetConnection(
self.host, self.port, self.username, self.password,
self.mode == 'ap')

self.last_results = {}

Expand Down
Expand Up @@ -13,7 +13,7 @@

import homeassistant.helpers.config_validation as cv
from homeassistant.core import split_entity_id, callback
from homeassistant.const import STATE_UNKNOWN
from homeassistant.const import STATE_UNKNOWN, CONF_REGION
from homeassistant.components.image_processing import (
PLATFORM_SCHEMA, ImageProcessingEntity, CONF_CONFIDENCE, CONF_SOURCE,
CONF_ENTITY_ID, CONF_NAME, ATTR_ENTITY_ID, ATTR_CONFIDENCE)
Expand Down Expand Up @@ -46,7 +46,6 @@
]

CONF_ALPR_BIN = 'alp_bin'
CONF_REGION = 'region'

DEFAULT_BINARY = 'alpr'

Expand Down
9 changes: 4 additions & 5 deletions homeassistant/components/input_number.py
Expand Up @@ -10,14 +10,14 @@

import voluptuous as vol

from homeassistant.config import load_yaml_config_file
import homeassistant.helpers.config_validation as cv
from homeassistant.config import load_yaml_config_file
from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_UNIT_OF_MEASUREMENT, CONF_ICON, CONF_NAME)
from homeassistant.loader import bind_hass
ATTR_ENTITY_ID, ATTR_UNIT_OF_MEASUREMENT, CONF_ICON, CONF_NAME, CONF_MODE)
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import async_get_last_state
from homeassistant.loader import bind_hass

_LOGGER = logging.getLogger(__name__)

Expand All @@ -27,7 +27,6 @@
CONF_INITIAL = 'initial'
CONF_MIN = 'min'
CONF_MAX = 'max'
CONF_MODE = 'mode'
CONF_STEP = 'step'

MODE_SLIDER = 'slider'
Expand Down Expand Up @@ -180,7 +179,7 @@ def async_handle_service(service):


class InputNumber(Entity):
"""Represent an slider."""
"""Representation of a slider."""

def __init__(self, object_id, name, initial, minimum, maximum, step, icon,
unit, mode):
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/sensor/google_travel_time.py
Expand Up @@ -14,7 +14,7 @@
from homeassistant.helpers.entity import Entity
from homeassistant.const import (
CONF_API_KEY, CONF_NAME, EVENT_HOMEASSISTANT_START, ATTR_LATITUDE,
ATTR_LONGITUDE)
ATTR_LONGITUDE, CONF_MODE)
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv
import homeassistant.helpers.location as location
Expand All @@ -25,7 +25,6 @@
_LOGGER = logging.getLogger(__name__)

CONF_DESTINATION = 'destination'
CONF_MODE = 'mode'
CONF_OPTIONS = 'options'
CONF_ORIGIN = 'origin'
CONF_TRAVEL_MODE = 'travel_mode'
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/sensor/uk_transport.py
Expand Up @@ -6,13 +6,15 @@
import logging
import re
from datetime import datetime, timedelta

import requests
import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_MODE
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

Expand All @@ -28,7 +30,6 @@
CONF_API_APP_KEY = 'app_key'
CONF_API_APP_ID = 'app_id'
CONF_QUERIES = 'queries'
CONF_MODE = 'mode'
CONF_ORIGIN = 'origin'
CONF_DESTINATION = 'destination'

Expand Down
10 changes: 5 additions & 5 deletions homeassistant/components/switch/flux.py
Expand Up @@ -11,20 +11,19 @@

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.light import (
is_on, turn_on, VALID_TRANSITION, ATTR_TRANSITION)
from homeassistant.components.switch import DOMAIN, SwitchDevice
from homeassistant.const import CONF_NAME, CONF_PLATFORM, CONF_LIGHTS
from homeassistant.const import (
CONF_NAME, CONF_PLATFORM, CONF_LIGHTS, CONF_MODE)
from homeassistant.helpers.event import track_time_change
from homeassistant.helpers.sun import get_astral_event_date
from homeassistant.util import slugify
from homeassistant.util.color import (
color_temperature_to_rgb, color_RGB_to_xy,
color_temperature_kelvin_to_mired)
from homeassistant.util.dt import now as dt_now
import homeassistant.helpers.config_validation as cv

DEPENDENCIES = ['light']

_LOGGER = logging.getLogger(__name__)

Expand All @@ -35,13 +34,14 @@
CONF_STOP_CT = 'stop_colortemp'
CONF_BRIGHTNESS = 'brightness'
CONF_DISABLE_BRIGTNESS_ADJUST = 'disable_brightness_adjust'
CONF_MODE = 'mode'
CONF_INTERVAL = 'interval'

MODE_XY = 'xy'
MODE_MIRED = 'mired'
MODE_RGB = 'rgb'
DEFAULT_MODE = MODE_XY
DEPENDENCIES = ['light']


PLATFORM_SCHEMA = vol.Schema({
vol.Required(CONF_PLATFORM): 'flux',
Expand Down
8 changes: 7 additions & 1 deletion homeassistant/const.py
Expand Up @@ -117,8 +117,9 @@
CONF_LIGHTS = 'lights'
CONF_MAC = 'mac'
CONF_METHOD = 'method'
CONF_MINIMUM = 'minimum'
CONF_MAXIMUM = 'maximum'
CONF_MINIMUM = 'minimum'
CONF_MODE = 'mode'
CONF_MONITORED_CONDITIONS = 'monitored_conditions'
CONF_MONITORED_VARIABLES = 'monitored_variables'
CONF_NAME = 'name'
Expand All @@ -135,10 +136,12 @@
CONF_PLATFORM = 'platform'
CONF_PORT = 'port'
CONF_PREFIX = 'prefix'
CONF_PROFILE_NAME = 'profile_name'
CONF_PROTOCOL = 'protocol'
CONF_PROXY_SSL = 'proxy_ssl'
CONF_QUOTE = 'quote'
CONF_RECIPIENT = 'recipient'
CONF_REGION = 'region'
CONF_RESOURCE = 'resource'
CONF_RESOURCES = 'resources'
CONF_RGB = 'rgb'
Expand Down Expand Up @@ -218,6 +221,9 @@
# Attribution
ATTR_ATTRIBUTION = 'attribution'

# Credentials
ATTR_CREDENTIALS = 'credentials'

# Contains time-related attributes
ATTR_NOW = 'now'
ATTR_DATE = 'date'
Expand Down