From 690760404b4a111ed10f91bd124aacb54f47dadd Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 29 Oct 2017 17:28:07 +0100 Subject: [PATCH] Move constant to 'const.py' and use already defined ones (#10211) --- homeassistant/components/notify/discord.py | 3 +- homeassistant/components/notify/ecobee.py | 4 +- homeassistant/components/notify/hipchat.py | 3 +- homeassistant/components/notify/rocketchat.py | 21 +++--- homeassistant/components/notify/xmpp.py | 4 +- homeassistant/components/sensor/airvisual.py | 3 +- homeassistant/components/sensor/citybikes.py | 56 +++++++-------- .../components/sensor/crimereports.py | 8 +-- .../components/sensor/geo_rss_events.py | 14 ++-- homeassistant/components/sensor/gitter.py | 4 +- homeassistant/components/sensor/mqtt_room.py | 12 ++-- homeassistant/components/sensor/opensky.py | 22 +++--- homeassistant/components/sensor/tado.py | 2 +- homeassistant/components/zone.py | 5 +- homeassistant/const.py | 72 ++++++++++--------- 15 files changed, 113 insertions(+), 120 deletions(-) diff --git a/homeassistant/components/notify/discord.py b/homeassistant/components/notify/discord.py index 07b13c60d1e..dca47a46dbf 100644 --- a/homeassistant/components/notify/discord.py +++ b/homeassistant/components/notify/discord.py @@ -12,13 +12,12 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.notify import ( PLATFORM_SCHEMA, BaseNotificationService, ATTR_TARGET) +from homeassistant.const import CONF_TOKEN _LOGGER = logging.getLogger(__name__) REQUIREMENTS = ['discord.py==0.16.12'] -CONF_TOKEN = 'token' - PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_TOKEN): cv.string }) diff --git a/homeassistant/components/notify/ecobee.py b/homeassistant/components/notify/ecobee.py index 2d64a2d5b47..c718149b4b5 100644 --- a/homeassistant/components/notify/ecobee.py +++ b/homeassistant/components/notify/ecobee.py @@ -8,14 +8,14 @@ import logging import voluptuous as vol +import homeassistant.helpers.config_validation as cv from homeassistant.components import ecobee from homeassistant.components.notify import ( BaseNotificationService, PLATFORM_SCHEMA) # NOQA -import homeassistant.helpers.config_validation as cv -DEPENDENCIES = ['ecobee'] _LOGGER = logging.getLogger(__name__) +DEPENDENCIES = ['ecobee'] CONF_INDEX = 'index' diff --git a/homeassistant/components/notify/hipchat.py b/homeassistant/components/notify/hipchat.py index ee1283b9820..344827c00b4 100644 --- a/homeassistant/components/notify/hipchat.py +++ b/homeassistant/components/notify/hipchat.py @@ -11,14 +11,13 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.notify import ( ATTR_TARGET, ATTR_DATA, PLATFORM_SCHEMA, BaseNotificationService) -from homeassistant.const import CONF_TOKEN, CONF_HOST +from homeassistant.const import CONF_TOKEN, CONF_HOST, CONF_ROOM REQUIREMENTS = ['hipnotify==1.0.8'] _LOGGER = logging.getLogger(__name__) CONF_COLOR = 'color' -CONF_ROOM = 'room' CONF_NOTIFY = 'notify' CONF_FORMAT = 'format' diff --git a/homeassistant/components/notify/rocketchat.py b/homeassistant/components/notify/rocketchat.py index f2898c8b998..e9b481b1cf3 100644 --- a/homeassistant/components/notify/rocketchat.py +++ b/homeassistant/components/notify/rocketchat.py @@ -8,17 +8,14 @@ import logging import voluptuous as vol -from homeassistant.const import ( - CONF_URL, CONF_USERNAME, CONF_PASSWORD) -from homeassistant.components.notify import ( - ATTR_DATA, PLATFORM_SCHEMA, - BaseNotificationService) import homeassistant.helpers.config_validation as cv +from homeassistant.const import ( + CONF_URL, CONF_USERNAME, CONF_PASSWORD, CONF_ROOM) +from homeassistant.components.notify import ( + ATTR_DATA, PLATFORM_SCHEMA, BaseNotificationService) REQUIREMENTS = ['rocketchat-API==0.6.1'] -CONF_ROOM = 'room' - _LOGGER = logging.getLogger(__name__) # pylint: disable=no-value-for-parameter @@ -44,11 +41,11 @@ def get_service(hass, config, discovery_info=None): return RocketChatNotificationService(url, username, password, room) except RocketConnectionException: _LOGGER.warning( - "Unable to connect to Rocket.Chat server at %s.", url) + "Unable to connect to Rocket.Chat server at %s", url) except RocketAuthenticationException: _LOGGER.warning( - "Rocket.Chat authentication failed for user %s.", username) - _LOGGER.info("Please check your username/password.") + "Rocket.Chat authentication failed for user %s", username) + _LOGGER.info("Please check your username/password") return None @@ -65,8 +62,8 @@ class RocketChatNotificationService(BaseNotificationService): def send_message(self, message="", **kwargs): """Send a message to Rocket.Chat.""" data = kwargs.get(ATTR_DATA) or {} - resp = self._server.chat_post_message(message, channel=self._room, - **data) + resp = self._server.chat_post_message( + message, channel=self._room, **data) if resp.status_code == 200: success = resp.json()["success"] if not success: diff --git a/homeassistant/components/notify/xmpp.py b/homeassistant/components/notify/xmpp.py index 455bab039f6..806acdb6d09 100644 --- a/homeassistant/components/notify/xmpp.py +++ b/homeassistant/components/notify/xmpp.py @@ -11,7 +11,8 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.notify import ( ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA, BaseNotificationService) -from homeassistant.const import CONF_PASSWORD, CONF_SENDER, CONF_RECIPIENT +from homeassistant.const import ( + CONF_PASSWORD, CONF_SENDER, CONF_RECIPIENT, CONF_ROOM) REQUIREMENTS = ['sleekxmpp==1.3.2', 'dnspython3==1.15.0', @@ -22,7 +23,6 @@ _LOGGER = logging.getLogger(__name__) CONF_TLS = 'tls' CONF_VERIFY = 'verify' -CONF_ROOM = 'room' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_SENDER): cv.string, diff --git a/homeassistant/components/sensor/airvisual.py b/homeassistant/components/sensor/airvisual.py index 82486a63d31..56ddf7adcab 100644 --- a/homeassistant/components/sensor/airvisual.py +++ b/homeassistant/components/sensor/airvisual.py @@ -14,7 +14,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_LATITUDE, ATTR_LONGITUDE, CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_MONITORED_CONDITIONS, CONF_STATE, - CONF_SHOW_ON_MAP) + CONF_SHOW_ON_MAP, CONF_RADIUS) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle @@ -31,7 +31,6 @@ ATTR_TIMESTAMP = 'timestamp' CONF_CITY = 'city' CONF_COUNTRY = 'country' -CONF_RADIUS = 'radius' CONF_ATTRIBUTION = "Data provided by AirVisual" MASS_PARTS_PER_MILLION = 'ppm' diff --git a/homeassistant/components/sensor/citybikes.py b/homeassistant/components/sensor/citybikes.py index a7bf7533e32..a13d2ca8d56 100644 --- a/homeassistant/components/sensor/citybikes.py +++ b/homeassistant/components/sensor/citybikes.py @@ -12,46 +12,50 @@ import aiohttp import async_timeout import voluptuous as vol +import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( - CONF_NAME, CONF_LATITUDE, CONF_LONGITUDE, + CONF_NAME, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS, ATTR_ATTRIBUTION, ATTR_LOCATION, ATTR_LATITUDE, ATTR_LONGITUDE, - ATTR_FRIENDLY_NAME, STATE_UNKNOWN, LENGTH_METERS, LENGTH_FEET) + ATTR_FRIENDLY_NAME, STATE_UNKNOWN, LENGTH_METERS, LENGTH_FEET, + ATTR_ID) from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.entity import Entity from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.util import location, distance -import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) +ATTR_EMPTY_SLOTS = 'empty_slots' +ATTR_EXTRA = 'extra' +ATTR_FREE_BIKES = 'free_bikes' +ATTR_NAME = 'name' +ATTR_NETWORK = 'network' +ATTR_NETWORKS_LIST = 'networks' +ATTR_STATIONS_LIST = 'stations' +ATTR_TIMESTAMP = 'timestamp' +ATTR_UID = 'uid' + +CONF_NETWORK = 'network' +CONF_STATIONS_LIST = 'stations' + DEFAULT_ENDPOINT = 'https://api.citybik.es/{uri}' +DOMAIN = 'citybikes' + +MONITORED_NETWORKS = 'monitored-networks' + NETWORKS_URI = 'v2/networks' -STATIONS_URI = 'v2/networks/{uid}?fields=network.stations' REQUEST_TIMEOUT = 5 # In seconds; argument to asyncio.timeout + SCAN_INTERVAL = timedelta(minutes=5) # Timely, and doesn't suffocate the API -DOMAIN = 'citybikes' -MONITORED_NETWORKS = 'monitored-networks' -CONF_NETWORK = 'network' -CONF_RADIUS = 'radius' -CONF_STATIONS_LIST = 'stations' -ATTR_NETWORKS_LIST = 'networks' -ATTR_NETWORK = 'network' -ATTR_STATIONS_LIST = 'stations' -ATTR_ID = 'id' -ATTR_UID = 'uid' -ATTR_NAME = 'name' -ATTR_EXTRA = 'extra' -ATTR_TIMESTAMP = 'timestamp' -ATTR_EMPTY_SLOTS = 'empty_slots' -ATTR_FREE_BIKES = 'free_bikes' -ATTR_TIMESTAMP = 'timestamp' + +STATIONS_URI = 'v2/networks/{uid}?fields=network.stations' + CITYBIKES_ATTRIBUTION = "Information provided by the CityBikes Project "\ "(https://citybik.es/#about)" - PLATFORM_SCHEMA = vol.All( cv.has_at_least_one_key(CONF_RADIUS, CONF_STATIONS_LIST), PLATFORM_SCHEMA.extend({ @@ -61,10 +65,7 @@ PLATFORM_SCHEMA = vol.All( vol.Inclusive(CONF_LONGITUDE, 'coordinates'): cv.longitude, vol.Optional(CONF_RADIUS, 'station_filter'): cv.positive_int, vol.Optional(CONF_STATIONS_LIST, 'station_filter'): - vol.All( - cv.ensure_list, - vol.Length(min=1), - [cv.string]) + vol.All(cv.ensure_list, vol.Length(min=1), [cv.string]) })) NETWORK_SCHEMA = vol.Schema({ @@ -88,9 +89,8 @@ STATION_SCHEMA = vol.Schema({ vol.Required(ATTR_ID): cv.string, vol.Required(ATTR_NAME): cv.string, vol.Required(ATTR_TIMESTAMP): cv.string, - vol.Optional(ATTR_EXTRA): vol.Schema({ - vol.Optional(ATTR_UID): cv.string - }, extra=vol.REMOVE_EXTRA) + vol.Optional(ATTR_EXTRA): + vol.Schema({vol.Optional(ATTR_UID): cv.string}, extra=vol.REMOVE_EXTRA) }, extra=vol.REMOVE_EXTRA) STATIONS_RESPONSE_SCHEMA = vol.Schema({ diff --git a/homeassistant/components/sensor/crimereports.py b/homeassistant/components/sensor/crimereports.py index b6e5ea33216..aecfca60bf1 100644 --- a/homeassistant/components/sensor/crimereports.py +++ b/homeassistant/components/sensor/crimereports.py @@ -13,7 +13,7 @@ import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_INCLUDE, CONF_EXCLUDE, CONF_NAME, CONF_LATITUDE, CONF_LONGITUDE, - ATTR_ATTRIBUTION, ATTR_LATITUDE, ATTR_LONGITUDE, + ATTR_ATTRIBUTION, ATTR_LATITUDE, ATTR_LONGITUDE, CONF_RADIUS, LENGTH_KILOMETERS, LENGTH_METERS) from homeassistant.helpers.entity import Entity from homeassistant.util import slugify @@ -25,8 +25,6 @@ REQUIREMENTS = ['crimereports==1.0.0'] _LOGGER = logging.getLogger(__name__) -CONF_RADIUS = 'radius' - DOMAIN = 'crimereports' EVENT_INCIDENT = '{}_incident'.format(DOMAIN) @@ -58,11 +56,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class CrimeReportsSensor(Entity): - """Crime Reports Sensor.""" + """Representation of a Crime Reports Sensor.""" def __init__(self, hass, name, latitude, longitude, radius, include, exclude): - """Initialize the sensor.""" + """Initialize the Crime Reports sensor.""" import crimereports self._hass = hass self._name = name diff --git a/homeassistant/components/sensor/geo_rss_events.py b/homeassistant/components/sensor/geo_rss_events.py index 484dd67e0e4..c8c4db17c8d 100644 --- a/homeassistant/components/sensor/geo_rss_events.py +++ b/homeassistant/components/sensor/geo_rss_events.py @@ -8,7 +8,6 @@ and grouped by category. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.geo_rss_events/ """ - import logging from collections import namedtuple from datetime import timedelta @@ -17,8 +16,8 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA -from homeassistant.const import (STATE_UNKNOWN, CONF_UNIT_OF_MEASUREMENT, - CONF_NAME) +from homeassistant.const import ( + STATE_UNKNOWN, CONF_UNIT_OF_MEASUREMENT, CONF_NAME, CONF_RADIUS, CONF_URL) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle @@ -31,8 +30,6 @@ ATTR_DISTANCE = 'distance' ATTR_TITLE = 'title' CONF_CATEGORIES = 'categories' -CONF_RADIUS = 'radius' -CONF_URL = 'url' DEFAULT_ICON = 'mdi:alert' DEFAULT_NAME = "Event Service" @@ -50,8 +47,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_URL): cv.string, vol.Optional(CONF_RADIUS, default=DEFAULT_RADIUS_IN_KM): vol.Coerce(float), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, - vol.Optional(CONF_CATEGORIES, default=[]): vol.All(cv.ensure_list, - [cv.string]), + vol.Optional(CONF_CATEGORIES, default=[]): + vol.All(cv.ensure_list, [cv.string]), vol.Optional(CONF_UNIT_OF_MEASUREMENT, default=DEFAULT_UNIT_OF_MEASUREMENT): cv.string, }) @@ -59,7 +56,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the GeoRSS component.""" - # Grab location from config home_latitude = hass.config.latitude home_longitude = hass.config.longitude url = config.get(CONF_URL) @@ -154,7 +150,7 @@ class GeoRssServiceSensor(Entity): class GeoRssServiceData(object): - """Provides access to GeoRSS feed and stores the latest data.""" + """Provide access to GeoRSS feed and stores the latest data.""" def __init__(self, home_latitude, home_longitude, url, radius_in_km): """Initialize the update service.""" diff --git a/homeassistant/components/sensor/gitter.py b/homeassistant/components/sensor/gitter.py index 69d6f75dc6d..58f33635750 100644 --- a/homeassistant/components/sensor/gitter.py +++ b/homeassistant/components/sensor/gitter.py @@ -10,7 +10,7 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA -from homeassistant.const import CONF_NAME, CONF_API_KEY +from homeassistant.const import CONF_NAME, CONF_API_KEY, CONF_ROOM from homeassistant.helpers.entity import Entity REQUIREMENTS = ['gitterpy==0.1.6'] @@ -21,8 +21,6 @@ ATTR_MENTION = 'mention' ATTR_ROOM = 'room' ATTR_USERNAME = 'username' -CONF_ROOM = 'room' - DEFAULT_NAME = 'Gitter messages' DEFAULT_ROOM = 'home-assistant/home-assistant' diff --git a/homeassistant/components/sensor/mqtt_room.py b/homeassistant/components/sensor/mqtt_room.py index 21198fa940b..40c6ce7458c 100644 --- a/homeassistant/components/sensor/mqtt_room.py +++ b/homeassistant/components/sensor/mqtt_room.py @@ -11,13 +11,13 @@ from datetime import timedelta import voluptuous as vol -from homeassistant.core import callback import homeassistant.components.mqtt as mqtt +import homeassistant.helpers.config_validation as cv +from homeassistant.components.mqtt import CONF_STATE_TOPIC from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( - CONF_NAME, CONF_TIMEOUT, STATE_NOT_HOME) -from homeassistant.components.mqtt import CONF_STATE_TOPIC -import homeassistant.helpers.config_validation as cv + CONF_NAME, CONF_TIMEOUT, STATE_NOT_HOME, ATTR_ID) +from homeassistant.core import callback from homeassistant.helpers.entity import Entity from homeassistant.util import dt, slugify @@ -27,16 +27,14 @@ DEPENDENCIES = ['mqtt'] ATTR_DEVICE_ID = 'device_id' ATTR_DISTANCE = 'distance' -ATTR_ID = 'id' ATTR_ROOM = 'room' CONF_DEVICE_ID = 'device_id' -CONF_ROOM = 'room' CONF_AWAY_TIMEOUT = 'away_timeout' +DEFAULT_AWAY_TIMEOUT = 0 DEFAULT_NAME = 'Room Sensor' DEFAULT_TIMEOUT = 5 -DEFAULT_AWAY_TIMEOUT = 0 DEFAULT_TOPIC = 'room_presence' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ diff --git a/homeassistant/components/sensor/opensky.py b/homeassistant/components/sensor/opensky.py index 43c9177f960..bd071ace578 100644 --- a/homeassistant/components/sensor/opensky.py +++ b/homeassistant/components/sensor/opensky.py @@ -10,27 +10,29 @@ from datetime import 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_NAME, CONF_LATITUDE, CONF_LONGITUDE, + CONF_NAME, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS, ATTR_ATTRIBUTION, ATTR_LATITUDE, ATTR_LONGITUDE, LENGTH_KILOMETERS, LENGTH_METERS) from homeassistant.helpers.entity import Entity from homeassistant.util import distance as util_distance from homeassistant.util import location as util_location -import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) -SCAN_INTERVAL = timedelta(seconds=12) # opensky public limit is 10 seconds -DOMAIN = 'opensky' -EVENT_OPENSKY_ENTRY = '{}_entry'.format(DOMAIN) -EVENT_OPENSKY_EXIT = '{}_exit'.format(DOMAIN) -CONF_RADIUS = 'radius' +ATTR_CALLSIGN = 'callsign' +ATTR_ON_GROUND = 'on_ground' ATTR_SENSOR = 'sensor' ATTR_STATES = 'states' -ATTR_ON_GROUND = 'on_ground' -ATTR_CALLSIGN = 'callsign' + +DOMAIN = 'opensky' + +EVENT_OPENSKY_ENTRY = '{}_entry'.format(DOMAIN) +EVENT_OPENSKY_EXIT = '{}_exit'.format(DOMAIN) +SCAN_INTERVAL = timedelta(seconds=12) # opensky public limit is 10 seconds + OPENSKY_ATTRIBUTION = "Information provided by the OpenSky Network "\ "(https://opensky-network.org)" OPENSKY_API_URL = 'https://opensky-network.org/api/states/all' @@ -88,7 +90,7 @@ class OpenSkySensor(Entity): for callsign in callsigns: data = { ATTR_CALLSIGN: callsign, - ATTR_SENSOR: self._name + ATTR_SENSOR: self._name, } self._hass.bus.fire(event, data) diff --git a/homeassistant/components/sensor/tado.py b/homeassistant/components/sensor/tado.py index 1d40e4ceb50..781f2e006d9 100644 --- a/homeassistant/components/sensor/tado.py +++ b/homeassistant/components/sensor/tado.py @@ -9,12 +9,12 @@ import logging from homeassistant.const import TEMP_CELSIUS from homeassistant.helpers.entity import Entity from homeassistant.components.tado import (DATA_TADO) +from homeassistant.const import (ATTR_ID) _LOGGER = logging.getLogger(__name__) ATTR_DATA_ID = 'data_id' ATTR_DEVICE = 'device' -ATTR_ID = 'id' ATTR_NAME = 'name' ATTR_ZONE = 'zone' diff --git a/homeassistant/components/zone.py b/homeassistant/components/zone.py index 712abfb1b6e..9ba503e6666 100644 --- a/homeassistant/components/zone.py +++ b/homeassistant/components/zone.py @@ -9,15 +9,15 @@ import logging import voluptuous as vol +import homeassistant.helpers.config_validation as cv from homeassistant.const import ( ATTR_HIDDEN, ATTR_LATITUDE, ATTR_LONGITUDE, CONF_NAME, CONF_LATITUDE, - CONF_LONGITUDE, CONF_ICON) + CONF_LONGITUDE, CONF_ICON, CONF_RADIUS) from homeassistant.loader import bind_hass from homeassistant.helpers import config_per_platform from homeassistant.helpers.entity import Entity, async_generate_entity_id from homeassistant.util.async import run_callback_threadsafe from homeassistant.util.location import distance -import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) @@ -25,7 +25,6 @@ ATTR_PASSIVE = 'passive' ATTR_RADIUS = 'radius' CONF_PASSIVE = 'passive' -CONF_RADIUS = 'radius' DEFAULT_NAME = 'Unnamed zone' DEFAULT_PASSIVE = False diff --git a/homeassistant/const.py b/homeassistant/const.py index 626dc3c8da4..97bb3a01975 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -140,11 +140,13 @@ CONF_PROFILE_NAME = 'profile_name' CONF_PROTOCOL = 'protocol' CONF_PROXY_SSL = 'proxy_ssl' CONF_QUOTE = 'quote' +CONF_RADIUS = 'radius' CONF_RECIPIENT = 'recipient' CONF_REGION = 'region' CONF_RESOURCE = 'resource' CONF_RESOURCES = 'resources' CONF_RGB = 'rgb' +CONF_ROOM = 'room' CONF_SCAN_INTERVAL = 'scan_interval' CONF_SENDER = 'sender' CONF_SENSOR_TYPE = 'sensor_type' @@ -234,6 +236,9 @@ ATTR_DOMAIN = 'domain' ATTR_SERVICE = 'service' ATTR_SERVICE_DATA = 'service_data' +# IDs +ATTR_ID = 'id' + # Data for a SERVICE_EXECUTED event ATTR_SERVICE_CALL_ID = 'service_call_id' @@ -258,38 +263,6 @@ CONF_UNIT_SYSTEM_IMPERIAL = 'imperial' # type: str # Electrical attributes ATTR_VOLTAGE = 'voltage' -# Temperature attribute -ATTR_TEMPERATURE = 'temperature' -TEMP_CELSIUS = '°C' -TEMP_FAHRENHEIT = '°F' - -# Length units -LENGTH_CENTIMETERS = 'cm' # type: str -LENGTH_METERS = 'm' # type: str -LENGTH_KILOMETERS = 'km' # type: str - -LENGTH_INCHES = 'in' # type: str -LENGTH_FEET = 'ft' # type: str -LENGTH_YARD = 'yd' # type: str -LENGTH_MILES = 'mi' # type: str - -# Volume units -VOLUME_LITERS = 'L' # type: str -VOLUME_MILLILITERS = 'mL' # type: str - -VOLUME_GALLONS = 'gal' # type: str -VOLUME_FLUID_OUNCE = 'fl. oz.' # type: str - -# Mass units -MASS_GRAMS = 'g' # type: str -MASS_KILOGRAMS = 'kg' # type: str - -MASS_OUNCES = 'oz' # type: str -MASS_POUNDS = 'lb' # type: str - -# UV Index units -UNIT_UV_INDEX = 'UV index' # type: str - # Contains the information that is discovered ATTR_DISCOVERED = 'discovered' @@ -341,6 +314,41 @@ ATTR_SUPPORTED_FEATURES = 'supported_features' # Class of device within its domain ATTR_DEVICE_CLASS = 'device_class' +# Temperature attribute +ATTR_TEMPERATURE = 'temperature' + +# #### UNITS OF MEASUREMENT #### +# Temperature units +TEMP_CELSIUS = '°C' +TEMP_FAHRENHEIT = '°F' + +# Length units +LENGTH_CENTIMETERS = 'cm' # type: str +LENGTH_METERS = 'm' # type: str +LENGTH_KILOMETERS = 'km' # type: str + +LENGTH_INCHES = 'in' # type: str +LENGTH_FEET = 'ft' # type: str +LENGTH_YARD = 'yd' # type: str +LENGTH_MILES = 'mi' # type: str + +# Volume units +VOLUME_LITERS = 'L' # type: str +VOLUME_MILLILITERS = 'mL' # type: str + +VOLUME_GALLONS = 'gal' # type: str +VOLUME_FLUID_OUNCE = 'fl. oz.' # type: str + +# Mass units +MASS_GRAMS = 'g' # type: str +MASS_KILOGRAMS = 'kg' # type: str + +MASS_OUNCES = 'oz' # type: str +MASS_POUNDS = 'lb' # type: str + +# UV Index units +UNIT_UV_INDEX = 'UV index' # type: str + # #### SERVICES #### SERVICE_HOMEASSISTANT_STOP = 'stop' SERVICE_HOMEASSISTANT_RESTART = 'restart'