diff --git a/homeassistant/components/buienradar/camera.py b/homeassistant/components/buienradar/camera.py index 439921928d65..1963041bccad 100644 --- a/homeassistant/components/buienradar/camera.py +++ b/homeassistant/components/buienradar/camera.py @@ -10,19 +10,13 @@ import voluptuous as vol from homeassistant.components.camera import Camera from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE +from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.util import dt as dt_util -from .const import ( - CONF_COUNTRY, - CONF_DELTA, - DEFAULT_COUNTRY, - DEFAULT_DELTA, - DEFAULT_DIMENSION, -) +from .const import CONF_DELTA, DEFAULT_COUNTRY, DEFAULT_DELTA, DEFAULT_DIMENSION _LOGGER = logging.getLogger(__name__) @@ -40,7 +34,9 @@ async def async_setup_entry( config = entry.data options = entry.options - country = options.get(CONF_COUNTRY, config.get(CONF_COUNTRY, DEFAULT_COUNTRY)) + country = options.get( + CONF_COUNTRY_CODE, config.get(CONF_COUNTRY_CODE, DEFAULT_COUNTRY) + ) delta = options.get(CONF_DELTA, config.get(CONF_DELTA, DEFAULT_DELTA)) diff --git a/homeassistant/components/buienradar/config_flow.py b/homeassistant/components/buienradar/config_flow.py index 4a81a774b4fb..1e77693f7fba 100644 --- a/homeassistant/components/buienradar/config_flow.py +++ b/homeassistant/components/buienradar/config_flow.py @@ -8,7 +8,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE +from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE from homeassistant.core import callback from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import selector @@ -20,7 +20,6 @@ from homeassistant.helpers.schema_config_entry_flow import ( ) from .const import ( - CONF_COUNTRY, CONF_DELTA, CONF_TIMEFRAME, DEFAULT_COUNTRY, @@ -32,7 +31,9 @@ from .const import ( OPTIONS_SCHEMA = vol.Schema( { - vol.Optional(CONF_COUNTRY, default=DEFAULT_COUNTRY): selector.CountrySelector( + vol.Optional( + CONF_COUNTRY_CODE, default=DEFAULT_COUNTRY + ): selector.CountrySelector( selector.CountrySelectorConfig(countries=SUPPORTED_COUNTRY_CODES) ), vol.Optional(CONF_DELTA, default=DEFAULT_DELTA): selector.NumberSelector( diff --git a/homeassistant/components/buienradar/const.py b/homeassistant/components/buienradar/const.py index 718812c5c731..c82970ed3188 100644 --- a/homeassistant/components/buienradar/const.py +++ b/homeassistant/components/buienradar/const.py @@ -8,7 +8,6 @@ DEFAULT_DIMENSION = 700 DEFAULT_DELTA = 600 CONF_DELTA = "delta" -CONF_COUNTRY = "country_code" CONF_TIMEFRAME = "timeframe" SUPPORTED_COUNTRY_CODES = ["NL", "BE"] diff --git a/homeassistant/components/co2signal/config_flow.py b/homeassistant/components/co2signal/config_flow.py index 234c1c01392a..dfa1e25d7d89 100644 --- a/homeassistant/components/co2signal/config_flow.py +++ b/homeassistant/components/co2signal/config_flow.py @@ -10,7 +10,12 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE +from homeassistant.const import ( + CONF_API_KEY, + CONF_COUNTRY_CODE, + CONF_LATITUDE, + CONF_LONGITUDE, +) from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv @@ -20,7 +25,7 @@ from homeassistant.helpers.selector import ( SelectSelectorMode, ) -from .const import CONF_COUNTRY_CODE, DOMAIN +from .const import DOMAIN from .helpers import fetch_latest_carbon_intensity from .util import get_extra_name diff --git a/homeassistant/components/co2signal/const.py b/homeassistant/components/co2signal/const.py index 1e0cbfe0f112..b025c655ce6c 100644 --- a/homeassistant/components/co2signal/const.py +++ b/homeassistant/components/co2signal/const.py @@ -2,5 +2,4 @@ DOMAIN = "co2signal" -CONF_COUNTRY_CODE = "country_code" ATTRIBUTION = "Data provided by Electricity Maps" diff --git a/homeassistant/components/co2signal/helpers.py b/homeassistant/components/co2signal/helpers.py index 43579c162e29..937b72a357ce 100644 --- a/homeassistant/components/co2signal/helpers.py +++ b/homeassistant/components/co2signal/helpers.py @@ -5,11 +5,9 @@ from typing import Any from aioelectricitymaps import ElectricityMaps from aioelectricitymaps.models import CarbonIntensityResponse -from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE +from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE from homeassistant.core import HomeAssistant -from .const import CONF_COUNTRY_CODE - async def fetch_latest_carbon_intensity( hass: HomeAssistant, diff --git a/homeassistant/components/co2signal/util.py b/homeassistant/components/co2signal/util.py index af0bec34904c..68403b4803e7 100644 --- a/homeassistant/components/co2signal/util.py +++ b/homeassistant/components/co2signal/util.py @@ -3,9 +3,7 @@ from __future__ import annotations from collections.abc import Mapping -from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE - -from .const import CONF_COUNTRY_CODE +from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE def get_extra_name(config: Mapping) -> str | None: diff --git a/homeassistant/components/picnic/__init__.py b/homeassistant/components/picnic/__init__.py index 6826d8940abb..d2f023af79f4 100644 --- a/homeassistant/components/picnic/__init__.py +++ b/homeassistant/components/picnic/__init__.py @@ -3,10 +3,10 @@ from python_picnic_api import PicnicAPI from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ACCESS_TOKEN, Platform +from homeassistant.const import CONF_ACCESS_TOKEN, CONF_COUNTRY_CODE, Platform from homeassistant.core import HomeAssistant -from .const import CONF_API, CONF_COORDINATOR, CONF_COUNTRY_CODE, DOMAIN +from .const import CONF_API, CONF_COORDINATOR, DOMAIN from .coordinator import PicnicUpdateCoordinator from .services import async_register_services diff --git a/homeassistant/components/picnic/config_flow.py b/homeassistant/components/picnic/config_flow.py index 65ae201482ac..b02c0a74bfce 100644 --- a/homeassistant/components/picnic/config_flow.py +++ b/homeassistant/components/picnic/config_flow.py @@ -12,10 +12,15 @@ import voluptuous as vol from homeassistant import config_entries, core, exceptions from homeassistant.config_entries import SOURCE_REAUTH -from homeassistant.const import CONF_ACCESS_TOKEN, CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import ( + CONF_ACCESS_TOKEN, + CONF_COUNTRY_CODE, + CONF_PASSWORD, + CONF_USERNAME, +) from homeassistant.data_entry_flow import FlowResult -from .const import CONF_COUNTRY_CODE, COUNTRY_CODES, DOMAIN +from .const import COUNTRY_CODES, DOMAIN _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/picnic/const.py b/homeassistant/components/picnic/const.py index 7e983321f3d6..a2543c177e4e 100644 --- a/homeassistant/components/picnic/const.py +++ b/homeassistant/components/picnic/const.py @@ -5,7 +5,6 @@ DOMAIN = "picnic" CONF_API = "api" CONF_COORDINATOR = "coordinator" -CONF_COUNTRY_CODE = "country_code" SERVICE_ADD_PRODUCT_TO_CART = "add_product" diff --git a/homeassistant/components/tuya/__init__.py b/homeassistant/components/tuya/__init__.py index 276d21f38219..d0ae13c09b70 100644 --- a/homeassistant/components/tuya/__init__.py +++ b/homeassistant/components/tuya/__init__.py @@ -15,6 +15,7 @@ from tuya_iot import ( ) from homeassistant.config_entries import ConfigEntry +from homeassistant.const import CONF_COUNTRY_CODE from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr @@ -25,7 +26,6 @@ from .const import ( CONF_ACCESS_SECRET, CONF_APP_TYPE, CONF_AUTH_TYPE, - CONF_COUNTRY_CODE, CONF_ENDPOINT, CONF_PASSWORD, CONF_USERNAME, diff --git a/homeassistant/components/tuya/config_flow.py b/homeassistant/components/tuya/config_flow.py index bf2c54a6158b..eb490791f7e1 100644 --- a/homeassistant/components/tuya/config_flow.py +++ b/homeassistant/components/tuya/config_flow.py @@ -7,13 +7,13 @@ from tuya_iot import AuthType, TuyaOpenAPI import voluptuous as vol from homeassistant import config_entries +from homeassistant.const import CONF_COUNTRY_CODE from .const import ( CONF_ACCESS_ID, CONF_ACCESS_SECRET, CONF_APP_TYPE, CONF_AUTH_TYPE, - CONF_COUNTRY_CODE, CONF_ENDPOINT, CONF_PASSWORD, CONF_USERNAME, diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index 19faa76a191e..56dbbc4fa404 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -38,7 +38,6 @@ CONF_ACCESS_ID = "access_id" CONF_ACCESS_SECRET = "access_secret" CONF_USERNAME = "username" CONF_PASSWORD = "password" -CONF_COUNTRY_CODE = "country_code" CONF_APP_TYPE = "tuya_app_type" TUYA_DISCOVERY_NEW = "tuya_discovery_new" diff --git a/homeassistant/components/tuya/diagnostics.py b/homeassistant/components/tuya/diagnostics.py index 454416970eaa..adac97174b91 100644 --- a/homeassistant/components/tuya/diagnostics.py +++ b/homeassistant/components/tuya/diagnostics.py @@ -9,20 +9,14 @@ from tuya_iot import TuyaDevice from homeassistant.components.diagnostics import REDACTED from homeassistant.config_entries import ConfigEntry +from homeassistant.const import CONF_COUNTRY_CODE from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers.device_registry import DeviceEntry from homeassistant.util import dt as dt_util from . import HomeAssistantTuyaData -from .const import ( - CONF_APP_TYPE, - CONF_AUTH_TYPE, - CONF_COUNTRY_CODE, - CONF_ENDPOINT, - DOMAIN, - DPCode, -) +from .const import CONF_APP_TYPE, CONF_AUTH_TYPE, CONF_ENDPOINT, DOMAIN, DPCode async def async_get_config_entry_diagnostics( diff --git a/homeassistant/const.py b/homeassistant/const.py index 8da1c251b4ef..df68e3ab05ab 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -129,6 +129,7 @@ CONF_CONTINUE_ON_ERROR: Final = "continue_on_error" CONF_CONTINUE_ON_TIMEOUT: Final = "continue_on_timeout" CONF_COUNT: Final = "count" CONF_COUNTRY: Final = "country" +CONF_COUNTRY_CODE: Final = "country_code" CONF_COVERS: Final = "covers" CONF_CURRENCY: Final = "currency" CONF_CUSTOMIZE: Final = "customize" diff --git a/tests/components/buienradar/test_camera.py b/tests/components/buienradar/test_camera.py index 027fde853c19..f048f8d69a77 100644 --- a/tests/components/buienradar/test_camera.py +++ b/tests/components/buienradar/test_camera.py @@ -6,8 +6,8 @@ from http import HTTPStatus from aiohttp.client_exceptions import ClientResponseError -from homeassistant.components.buienradar.const import CONF_COUNTRY, CONF_DELTA, DOMAIN -from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE +from homeassistant.components.buienradar.const import CONF_DELTA, DOMAIN +from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_registry import async_get from homeassistant.util import dt as dt_util @@ -144,7 +144,7 @@ async def test_belgium_country( aioclient_mock.get(radar_map_url(country_code="BE"), text="hello world") data = copy.deepcopy(TEST_CFG_DATA) - data[CONF_COUNTRY] = "BE" + data[CONF_COUNTRY_CODE] = "BE" mock_entry = MockConfigEntry(domain=DOMAIN, unique_id="TEST_ID", data=data) diff --git a/tests/components/picnic/test_config_flow.py b/tests/components/picnic/test_config_flow.py index a649240bd219..d90551b01df1 100644 --- a/tests/components/picnic/test_config_flow.py +++ b/tests/components/picnic/test_config_flow.py @@ -6,8 +6,8 @@ from python_picnic_api.session import PicnicAuthError import requests from homeassistant import config_entries, data_entry_flow -from homeassistant.components.picnic.const import CONF_COUNTRY_CODE, DOMAIN -from homeassistant.const import CONF_ACCESS_TOKEN +from homeassistant.components.picnic.const import DOMAIN +from homeassistant.const import CONF_ACCESS_TOKEN, CONF_COUNTRY_CODE from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry diff --git a/tests/components/picnic/test_sensor.py b/tests/components/picnic/test_sensor.py index cae10320fb9b..fb1fbe9f009f 100644 --- a/tests/components/picnic/test_sensor.py +++ b/tests/components/picnic/test_sensor.py @@ -9,11 +9,12 @@ import requests from homeassistant import config_entries from homeassistant.components.picnic import const -from homeassistant.components.picnic.const import CONF_COUNTRY_CODE, DOMAIN +from homeassistant.components.picnic.const import DOMAIN from homeassistant.components.picnic.sensor import SENSOR_TYPES from homeassistant.components.sensor import SensorDeviceClass from homeassistant.const import ( CONF_ACCESS_TOKEN, + CONF_COUNTRY_CODE, CURRENCY_EURO, STATE_UNAVAILABLE, STATE_UNKNOWN, diff --git a/tests/components/tuya/test_config_flow.py b/tests/components/tuya/test_config_flow.py index 0630114da903..9505e1ef423f 100644 --- a/tests/components/tuya/test_config_flow.py +++ b/tests/components/tuya/test_config_flow.py @@ -13,7 +13,6 @@ from homeassistant.components.tuya.const import ( CONF_ACCESS_SECRET, CONF_APP_TYPE, CONF_AUTH_TYPE, - CONF_COUNTRY_CODE, CONF_ENDPOINT, CONF_PASSWORD, CONF_USERNAME, @@ -22,6 +21,7 @@ from homeassistant.components.tuya.const import ( TUYA_COUNTRIES, TUYA_SMART_APP, ) +from homeassistant.const import CONF_COUNTRY_CODE from homeassistant.core import HomeAssistant MOCK_SMART_HOME_PROJECT_TYPE = 0