Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/alexa/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def _check_requirements(self):
return False

try:
network.async_get_url(
network.get_url(
self.hass,
allow_internal=False,
allow_ip=False,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/alexa/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ async def async_api_initialize_camera_stream(hass, config, directive, context):
camera_image = hass.states.get(entity.entity_id).attributes["entity_picture"]

try:
external_url = network.async_get_url(
external_url = network.get_url(
hass,
allow_internal=False,
allow_ip=False,
Expand Down
6 changes: 2 additions & 4 deletions homeassistant/components/almond/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,9 @@ async def _configure_almond_for_ha(
if entry.data["type"] == TYPE_OAUTH2:
# If we're connecting over OAuth2, we will only set up connection
# with Home Assistant if we're remotely accessible.
hass_url = network.async_get_url(
hass, allow_internal=False, prefer_cloud=True
)
hass_url = network.get_url(hass, allow_internal=False, prefer_cloud=True)
else:
hass_url = network.async_get_url(hass)
hass_url = network.get_url(hass)
except network.NoURLAvailableError:
# If no URL is available, we're not going to configure Almond to connect to HA.
return
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/ambiclimate/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant.components.http import HomeAssistantView
from homeassistant.core import callback
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url

from .const import (
AUTH_CALLBACK_NAME,
Expand Down Expand Up @@ -131,7 +131,7 @@ def _generate_oauth(self):
)

def _cb_url(self):
return f"{async_get_url(self.hass)}{AUTH_CALLBACK_PATH}"
return f"{get_url(self.hass)}{AUTH_CALLBACK_PATH}"

async def _get_authorize_url(self):
oauth = self._generate_oauth()
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
)
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url
from homeassistant.loader import bind_hass
from homeassistant.setup import async_when_setup

Expand Down Expand Up @@ -685,7 +685,7 @@ async def async_handle_play_stream_service(camera, service_call):
)
data = {
ATTR_ENTITY_ID: entity_ids,
ATTR_MEDIA_CONTENT_ID: f"{async_get_url(hass)}{url}",
ATTR_MEDIA_CONTENT_ID: f"{get_url(hass)}{url}",
ATTR_MEDIA_CONTENT_TYPE: FORMAT_CONTENT_TYPE[fmt],
}

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/cast/home_assistant_cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant import auth, config_entries, core
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.helpers import config_validation as cv, dispatcher
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url

from .const import DOMAIN, SIGNAL_HASS_CAST_SHOW_VIEW

Expand Down Expand Up @@ -41,7 +41,7 @@ async def async_setup_ha_cast(

async def handle_show_view(call: core.ServiceCall):
"""Handle a Show View service call."""
hass_url = async_get_url(hass, require_ssl=True)
hass_url = get_url(hass, require_ssl=True)

controller = HomeAssistantController(
# If you are developing Home Assistant Cast, uncomment and set to your dev app id.
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/doorbird/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url
from homeassistant.util import dt as dt_util, slugify

from .const import CONF_EVENTS, DOMAIN, DOOR_STATION, DOOR_STATION_INFO, PLATFORMS
Expand Down Expand Up @@ -253,7 +253,7 @@ def token(self):
def register_events(self, hass):
"""Register events on device."""
# Get the URL of this server
hass_url = async_get_url(hass)
hass_url = get_url(hass)

# Override url if another is specified in the configuration
if self.custom_url is not None:
Expand Down
10 changes: 5 additions & 5 deletions homeassistant/components/fitbit/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url
from homeassistant.util.json import load_json, save_json

_CONFIGURING = {}
Expand Down Expand Up @@ -181,7 +181,7 @@ def fitbit_configuration_callback(callback_data):
else:
setup_platform(hass, config, add_entities, discovery_info)

start_url = f"{async_get_url(hass)}{FITBIT_AUTH_CALLBACK_PATH}"
start_url = f"{get_url(hass)}{FITBIT_AUTH_CALLBACK_PATH}"

description = f"""Please create a Fitbit developer app at
https://dev.fitbit.com/apps/new.
Expand Down Expand Up @@ -216,7 +216,7 @@ def request_oauth_completion(hass):
def fitbit_configuration_callback(callback_data):
"""Handle configuration updates."""

start_url = f"{async_get_url(hass)}{FITBIT_AUTH_START}"
start_url = f"{get_url(hass)}{FITBIT_AUTH_START}"

description = f"Please authorize Fitbit by visiting {start_url}"

Expand Down Expand Up @@ -308,7 +308,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
config_file.get(ATTR_CLIENT_ID), config_file.get(ATTR_CLIENT_SECRET)
)

redirect_uri = f"{async_get_url(hass)}{FITBIT_AUTH_CALLBACK_PATH}"
redirect_uri = f"{get_url(hass)}{FITBIT_AUTH_CALLBACK_PATH}"

fitbit_auth_start_url, _ = oauth.authorize_token_url(
redirect_uri=redirect_uri,
Expand Down Expand Up @@ -353,7 +353,7 @@ def get(self, request):

result = None
if data.get("code") is not None:
redirect_uri = f"{async_get_url(hass)}{FITBIT_AUTH_CALLBACK_PATH}"
redirect_uri = f"{get_url(hass)}{FITBIT_AUTH_CALLBACK_PATH}"

try:
result = self.oauth.fetch_access_token(data.get("code"), redirect_uri)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/google_assistant/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
from homeassistant.core import Context, HomeAssistant, State, callback
from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url
from homeassistant.helpers.storage import Store

from . import trait
Expand Down Expand Up @@ -426,7 +426,7 @@ async def sync_serialize(self, agent_user_id):
"webhookId": self.config.local_sdk_webhook_id,
"httpPort": self.hass.http.server_port,
"httpSSL": self.hass.config.api.use_ssl,
"baseUrl": async_get_url(self.hass, prefer_external=True),
"baseUrl": get_url(self.hass, prefer_external=True),
"proxyDeviceId": agent_user_id,
}

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/google_assistant/trait.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
TEMP_FAHRENHEIT,
)
from homeassistant.core import DOMAIN as HA_DOMAIN
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url
from homeassistant.util import color as color_util, temperature as temp_util

from .const import (
Expand Down Expand Up @@ -248,7 +248,7 @@ async def execute(self, command, data, params, challenge):
url = await self.hass.components.camera.async_request_stream(
self.state.entity_id, "hls"
)
self.stream_info = {"cameraStreamAccessUrl": f"{async_get_url(self.hass)}{url}"}
self.stream_info = {"cameraStreamAccessUrl": f"{get_url(self.hass)}{url}"}


@register_trait
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def base_url(self) -> str:
extra = ""

_LOGGER.warning(
"Detected use of deprecated `base_url` property, use `homeassistant.helpers.network.async_get_url` method instead. Please report issue%s for %s using this method at %s, line %s: %s",
"Detected use of deprecated `base_url` property, use `homeassistant.helpers.network.get_url` method instead. Please report issue%s for %s using this method at %s, line %s: %s",
extra,
integration,
found_frame.filename[index:],
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/konnected/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from homeassistant.core import callback
from homeassistant.helpers import aiohttp_client, device_registry as dr
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url

from .const import (
CONF_ACTIVATION,
Expand Down Expand Up @@ -298,7 +298,7 @@ def async_desired_settings_payload(self):
# keeping self.hass.data check for backwards compatibility
# newly configured integrations store this in the config entry
desired_api_host = self.options.get(CONF_API_HOST) or (
self.hass.data[DOMAIN].get(CONF_API_HOST) or async_get_url(self.hass)
self.hass.data[DOMAIN].get(CONF_API_HOST) or get_url(self.hass)
)
desired_api_endpoint = desired_api_host + ENDPOINT_ROOT

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/media_player/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
)
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url
from homeassistant.loader import bind_hass

from .const import (
Expand Down Expand Up @@ -821,7 +821,7 @@ async def _async_fetch_image(hass, url):
cache_maxsize = ENTITY_IMAGE_CACHE[CACHE_MAXSIZE]

if urlparse(url).hostname is None:
url = f"{async_get_url(hass)}{url}"
url = f"{get_url(hass)}{url}"

if url not in cache_images:
cache_images[url] = {CACHE_LOCK: asyncio.Lock()}
Expand Down
6 changes: 2 additions & 4 deletions homeassistant/components/plex/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from homeassistant.core import callback
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url

from .const import ( # pylint: disable=unused-import
AUTH_CALLBACK_NAME,
Expand Down Expand Up @@ -280,9 +280,7 @@ async def async_step_plex_website_auth(self):
session = async_get_clientsession(self.hass)
self.plexauth = PlexAuth(payload, session)
await self.plexauth.initiate_auth()
forward_url = (
f"{async_get_url(self.hass)}{AUTH_CALLBACK_PATH}?flow_id={self.flow_id}"
)
forward_url = f"{get_url(self.hass)}{AUTH_CALLBACK_PATH}?flow_id={self.flow_id}"
auth_url = self.plexauth.auth_url(forward_url)
return self.async_external_step(step_id="obtain_token", url=auth_url)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/smartthings/smartapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
async_dispatcher_connect,
async_dispatcher_send,
)
from homeassistant.helpers.network import NoURLAvailableError, async_get_url
from homeassistant.helpers.network import NoURLAvailableError, get_url
from homeassistant.helpers.typing import HomeAssistantType

from .const import (
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_webhook_url(hass: HomeAssistantType) -> str:

def _get_app_template(hass: HomeAssistantType):
try:
endpoint = f"at {async_get_url(hass, allow_cloud=False, prefer_external=True)}"
endpoint = f"at {get_url(hass, allow_cloud=False, prefer_external=True)}"
except NoURLAvailableError:
endpoint = ""

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/telegram_bot/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
HTTP_BAD_REQUEST,
HTTP_UNAUTHORIZED,
)
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url

from . import (
CONF_ALLOWED_CHAT_IDS,
Expand All @@ -34,7 +34,7 @@ async def async_setup_platform(hass, config):

current_status = await hass.async_add_job(bot.getWebhookInfo)
base_url = config.get(
CONF_URL, async_get_url(hass, require_ssl=True, allow_internal=False)
CONF_URL, get_url(hass, require_ssl=True, allow_internal=False)
)

# Some logging of Bot current status:
Expand Down
12 changes: 5 additions & 7 deletions homeassistant/components/tts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_per_platform, discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.setup import async_prepare_setup_platform

Expand Down Expand Up @@ -115,7 +115,7 @@ async def async_setup(hass, config):
use_cache = conf.get(CONF_CACHE, DEFAULT_CACHE)
cache_dir = conf.get(CONF_CACHE_DIR, DEFAULT_CACHE_DIR)
time_memory = conf.get(CONF_TIME_MEMORY, DEFAULT_TIME_MEMORY)
base_url = conf.get(CONF_BASE_URL) or async_get_url(hass)
base_url = conf.get(CONF_BASE_URL) or get_url(hass)

await tts.async_init_cache(use_cache, cache_dir, time_memory, base_url)
except (HomeAssistantError, KeyError) as err:
Expand Down Expand Up @@ -162,7 +162,7 @@ async def async_say_handle(service):
options = service.data.get(ATTR_OPTIONS)

try:
url = await tts.async_get_url(
url = await tts.get_url(
p_type, message, cache=cache, language=language, options=options
)
except HomeAssistantError as err:
Expand Down Expand Up @@ -273,9 +273,7 @@ def async_register_engine(self, engine, provider, config):
provider.name = engine
self.providers[engine] = provider

async def async_get_url(
self, engine, message, cache=None, language=None, options=None
):
async def get_url(self, engine, message, cache=None, language=None, options=None):
Comment thread
frenck marked this conversation as resolved.
Outdated
"""Get URL for play message.

This method is a coroutine.
Expand Down Expand Up @@ -549,7 +547,7 @@ async def post(self, request):
options = data.get(ATTR_OPTIONS)

try:
url = await self.tts.async_get_url(
url = await self.tts.get_url(
p_type, message, cache=cache, language=language, options=options
)
resp = self.json({"url": url}, HTTP_OK)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/webhook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from homeassistant.components.http.view import HomeAssistantView
from homeassistant.const import HTTP_OK
from homeassistant.core import callback
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url
from homeassistant.loader import bind_hass

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -57,7 +57,7 @@ def async_generate_id():
def async_generate_url(hass, webhook_id):
"""Generate the full URL for a webhook_id."""
return "{}{}".format(
async_get_url(hass, prefer_external=True, allow_cloud=False),
get_url(hass, prefer_external=True, allow_cloud=False),
async_generate_path(webhook_id),
)

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/wink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.event import track_time_interval
from homeassistant.helpers.network import async_get_url
from homeassistant.helpers.network import get_url
from homeassistant.util.json import load_json, save_json

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -232,7 +232,7 @@ def wink_configuration_callback(callback_data):
_configurator = hass.data[DOMAIN]["configuring"][DOMAIN]
configurator.notify_errors(_configurator, error_msg)

start_url = f"{async_get_url(hass)}{WINK_AUTH_CALLBACK_PATH}"
start_url = f"{get_url(hass)}{WINK_AUTH_CALLBACK_PATH}"

description = f"""Please create a Wink developer app at
https://developer.wink.com.
Expand Down Expand Up @@ -270,7 +270,7 @@ def wink_configuration_callback(callback_data):
"""Call setup again."""
setup(hass, config)

start_url = f"{async_get_url(hass)}{WINK_AUTH_START}"
start_url = f"{get_url(hass)}{WINK_AUTH_START}"

description = f"Please authorize Wink by visiting {start_url}"

Expand Down Expand Up @@ -350,7 +350,7 @@ def setup(hass, config):
# Home .
else:

redirect_uri = f"{async_get_url(hass)}{WINK_AUTH_CALLBACK_PATH}"
redirect_uri = f"{get_url(hass)}{WINK_AUTH_CALLBACK_PATH}"

wink_auth_start_url = pywink.get_authorization_url(
config_file.get(ATTR_CLIENT_ID), redirect_uri
Expand Down
Loading