From aa013fa8f6abed738097e8045d319117451e09ab Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Sat, 26 Mar 2022 00:10:54 -0400 Subject: [PATCH] Add CONF_LOCATION constant (#68474) * Add CONF_LOCATION constant * Update all custom CONF_LOCATION definitions to point to constant * remove CONF_LOCATION from homeassistant/components/totalconnect/const --- homeassistant/components/ambient_station/diagnostics.py | 3 +-- homeassistant/components/pi_hole/__init__.py | 2 +- homeassistant/components/pi_hole/config_flow.py | 2 +- homeassistant/components/pi_hole/const.py | 1 - homeassistant/components/simplisafe/diagnostics.py | 3 +-- homeassistant/components/spaceapi/__init__.py | 2 +- homeassistant/components/tapsaff/binary_sensor.py | 4 +--- homeassistant/components/totalconnect/config_flow.py | 4 +--- homeassistant/components/totalconnect/const.py | 1 - homeassistant/const.py | 1 + tests/components/pi_hole/__init__.py | 3 ++- tests/components/pi_hole/test_init.py | 2 +- 12 files changed, 11 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/ambient_station/diagnostics.py b/homeassistant/components/ambient_station/diagnostics.py index cb9c7adab18..6005b206954 100644 --- a/homeassistant/components/ambient_station/diagnostics.py +++ b/homeassistant/components/ambient_station/diagnostics.py @@ -5,7 +5,7 @@ from typing import Any from homeassistant.components.diagnostics import async_redact_data from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_API_KEY +from homeassistant.const import CONF_API_KEY, CONF_LOCATION from homeassistant.core import HomeAssistant from . import AmbientStation @@ -14,7 +14,6 @@ from .const import CONF_APP_KEY, DOMAIN CONF_API_KEY_CAMEL = "apiKey" CONF_APP_KEY_CAMEL = "appKey" CONF_DEVICE_ID_CAMEL = "deviceId" -CONF_LOCATION = "location" CONF_MAC_ADDRESS = "mac_address" CONF_MAC_ADDRESS_CAMEL = "macAddress" CONF_TZ = "tz" diff --git a/homeassistant/components/pi_hole/__init__.py b/homeassistant/components/pi_hole/__init__.py index 3e18953af84..07b81a2702e 100644 --- a/homeassistant/components/pi_hole/__init__.py +++ b/homeassistant/components/pi_hole/__init__.py @@ -11,6 +11,7 @@ from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( CONF_API_KEY, CONF_HOST, + CONF_LOCATION, CONF_NAME, CONF_SSL, CONF_VERIFY_SSL, @@ -29,7 +30,6 @@ from homeassistant.helpers.update_coordinator import ( ) from .const import ( - CONF_LOCATION, CONF_STATISTICS_ONLY, DATA_KEY_API, DATA_KEY_COORDINATOR, diff --git a/homeassistant/components/pi_hole/config_flow.py b/homeassistant/components/pi_hole/config_flow.py index 39d47ecdd74..40f4555e7d2 100644 --- a/homeassistant/components/pi_hole/config_flow.py +++ b/homeassistant/components/pi_hole/config_flow.py @@ -12,6 +12,7 @@ from homeassistant import config_entries from homeassistant.const import ( CONF_API_KEY, CONF_HOST, + CONF_LOCATION, CONF_NAME, CONF_PORT, CONF_SSL, @@ -21,7 +22,6 @@ from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import ( - CONF_LOCATION, CONF_STATISTICS_ONLY, DEFAULT_LOCATION, DEFAULT_NAME, diff --git a/homeassistant/components/pi_hole/const.py b/homeassistant/components/pi_hole/const.py index 38819d29df4..69e8ecacdaa 100644 --- a/homeassistant/components/pi_hole/const.py +++ b/homeassistant/components/pi_hole/const.py @@ -17,7 +17,6 @@ from homeassistant.const import PERCENTAGE DOMAIN = "pi_hole" -CONF_LOCATION = "location" CONF_STATISTICS_ONLY = "statistics_only" DEFAULT_LOCATION = "admin" diff --git a/homeassistant/components/simplisafe/diagnostics.py b/homeassistant/components/simplisafe/diagnostics.py index c7c03467c94..dac89715c10 100644 --- a/homeassistant/components/simplisafe/diagnostics.py +++ b/homeassistant/components/simplisafe/diagnostics.py @@ -5,7 +5,7 @@ from typing import Any from homeassistant.components.diagnostics import async_redact_data from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ADDRESS +from homeassistant.const import CONF_ADDRESS, CONF_LOCATION from homeassistant.core import HomeAssistant from . import SimpliSafe @@ -13,7 +13,6 @@ from .const import DOMAIN CONF_CREDIT_CARD = "creditCard" CONF_EXPIRES = "expires" -CONF_LOCATION = "location" CONF_LOCATION_NAME = "locationName" CONF_PAYMENT_PROFILE_ID = "paymentProfileId" CONF_SERIAL = "serial" diff --git a/homeassistant/components/spaceapi/__init__.py b/homeassistant/components/spaceapi/__init__.py index e2ca5b972f8..c18f150a925 100644 --- a/homeassistant/components/spaceapi/__init__.py +++ b/homeassistant/components/spaceapi/__init__.py @@ -14,6 +14,7 @@ from homeassistant.const import ( CONF_ADDRESS, CONF_EMAIL, CONF_ENTITY_ID, + CONF_LOCATION, CONF_SENSORS, CONF_STATE, CONF_URL, @@ -55,7 +56,6 @@ CONF_ICON_OPEN = "icon_open" CONF_ICONS = "icons" CONF_IRC = "irc" CONF_ISSUE_REPORT_CHANNELS = "issue_report_channels" -CONF_LOCATION = "location" CONF_SPACEFED = "spacefed" CONF_SPACENET = "spacenet" CONF_SPACESAML = "spacesaml" diff --git a/homeassistant/components/tapsaff/binary_sensor.py b/homeassistant/components/tapsaff/binary_sensor.py index 3d82da340e9..9608971e78a 100644 --- a/homeassistant/components/tapsaff/binary_sensor.py +++ b/homeassistant/components/tapsaff/binary_sensor.py @@ -8,7 +8,7 @@ from tapsaff import TapsAff import voluptuous as vol from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity -from homeassistant.const import CONF_NAME +from homeassistant.const import CONF_LOCATION, CONF_NAME from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -16,8 +16,6 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) -CONF_LOCATION = "location" - DEFAULT_NAME = "Taps Aff" SCAN_INTERVAL = timedelta(minutes=30) diff --git a/homeassistant/components/totalconnect/config_flow.py b/homeassistant/components/totalconnect/config_flow.py index b529bdd80fd..013b08b50be 100644 --- a/homeassistant/components/totalconnect/config_flow.py +++ b/homeassistant/components/totalconnect/config_flow.py @@ -4,12 +4,10 @@ from total_connect_client.exceptions import AuthenticationError import voluptuous as vol from homeassistant import config_entries -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_LOCATION, CONF_PASSWORD, CONF_USERNAME from .const import CONF_USERCODES, DOMAIN -CONF_LOCATION = "location" - PASSWORD_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str}) diff --git a/homeassistant/components/totalconnect/const.py b/homeassistant/components/totalconnect/const.py index 22ecd14281f..ba217bd4ca7 100644 --- a/homeassistant/components/totalconnect/const.py +++ b/homeassistant/components/totalconnect/const.py @@ -2,7 +2,6 @@ DOMAIN = "totalconnect" CONF_USERCODES = "usercodes" -CONF_LOCATION = "location" # Most TotalConnect alarms will work passing '-1' as usercode DEFAULT_USERCODE = "-1" diff --git a/homeassistant/const.py b/homeassistant/const.py index 2c2676d8bb4..cf8f04ed4d9 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -169,6 +169,7 @@ CONF_IP_ADDRESS: Final = "ip_address" CONF_LATITUDE: Final = "latitude" CONF_LEGACY_TEMPLATES: Final = "legacy_templates" CONF_LIGHTS: Final = "lights" +CONF_LOCATION: Final = "location" CONF_LONGITUDE: Final = "longitude" CONF_MAC: Final = "mac" CONF_MAXIMUM: Final = "maximum" diff --git a/tests/components/pi_hole/__init__.py b/tests/components/pi_hole/__init__.py index 235cce92a4b..f45c05cfe74 100644 --- a/tests/components/pi_hole/__init__.py +++ b/tests/components/pi_hole/__init__.py @@ -3,10 +3,11 @@ from unittest.mock import AsyncMock, MagicMock, patch from hole.exceptions import HoleError -from homeassistant.components.pi_hole.const import CONF_LOCATION, CONF_STATISTICS_ONLY +from homeassistant.components.pi_hole.const import CONF_STATISTICS_ONLY from homeassistant.const import ( CONF_API_KEY, CONF_HOST, + CONF_LOCATION, CONF_NAME, CONF_PORT, CONF_SSL, diff --git a/tests/components/pi_hole/test_init.py b/tests/components/pi_hole/test_init.py index e96f0d7b33f..9c336f8bb6d 100644 --- a/tests/components/pi_hole/test_init.py +++ b/tests/components/pi_hole/test_init.py @@ -6,7 +6,6 @@ from hole.exceptions import HoleError from homeassistant.components import pi_hole, switch from homeassistant.components.pi_hole.const import ( - CONF_LOCATION, CONF_STATISTICS_ONLY, DEFAULT_LOCATION, DEFAULT_NAME, @@ -19,6 +18,7 @@ from homeassistant.const import ( ATTR_ENTITY_ID, CONF_API_KEY, CONF_HOST, + CONF_LOCATION, CONF_NAME, CONF_SSL, CONF_VERIFY_SSL,