mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Add hints to get_service in kodi (#86698)
This commit is contained in:
parent
cbcff6435f
commit
1139555448
@ -1,4 +1,6 @@
|
|||||||
"""Kodi notification service."""
|
"""Kodi notification service."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@ -20,8 +22,10 @@ from homeassistant.const import (
|
|||||||
CONF_PROXY_SSL,
|
CONF_PROXY_SSL,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -42,15 +46,17 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
ATTR_DISPLAYTIME = "displaytime"
|
ATTR_DISPLAYTIME = "displaytime"
|
||||||
|
|
||||||
|
|
||||||
async def async_get_service(hass, config, discovery_info=None):
|
async def async_get_service(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> KodiNotificationService:
|
||||||
"""Return the notify service."""
|
"""Return the notify service."""
|
||||||
url = f"{config.get(CONF_HOST)}:{config.get(CONF_PORT)}"
|
username: str | None = config.get(CONF_USERNAME)
|
||||||
|
password: str | None = config.get(CONF_PASSWORD)
|
||||||
|
|
||||||
username = config.get(CONF_USERNAME)
|
host: str = config[CONF_HOST]
|
||||||
password = config.get(CONF_PASSWORD)
|
port: int = config[CONF_PORT]
|
||||||
|
|
||||||
host = config.get(CONF_HOST)
|
|
||||||
port = config.get(CONF_PORT)
|
|
||||||
encryption = config.get(CONF_PROXY_SSL)
|
encryption = config.get(CONF_PROXY_SSL)
|
||||||
|
|
||||||
if host.startswith("http://") or host.startswith("https://"):
|
if host.startswith("http://") or host.startswith("https://"):
|
||||||
@ -64,7 +70,7 @@ async def async_get_service(hass, config, discovery_info=None):
|
|||||||
http_protocol = "https" if encryption else "http"
|
http_protocol = "https" if encryption else "http"
|
||||||
url = f"{http_protocol}://{host}:{port}/jsonrpc"
|
url = f"{http_protocol}://{host}:{port}/jsonrpc"
|
||||||
|
|
||||||
if username is not None:
|
if username is not None and password is not None:
|
||||||
auth = aiohttp.BasicAuth(username, password)
|
auth = aiohttp.BasicAuth(username, password)
|
||||||
else:
|
else:
|
||||||
auth = None
|
auth = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user