mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add hints to get_service in joaoapps join (#86699)
This commit is contained in:
parent
fea30c1ce9
commit
cbcff6435f
@ -1,4 +1,6 @@
|
|||||||
"""Support for Join notifications."""
|
"""Support for Join notifications."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pyjoin import get_devices, send_notification
|
from pyjoin import get_devices, send_notification
|
||||||
@ -12,7 +14,9 @@ from homeassistant.components.notify import (
|
|||||||
BaseNotificationService,
|
BaseNotificationService,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_DEVICE_ID
|
from homeassistant.const import CONF_API_KEY, CONF_DEVICE_ID
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
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__)
|
||||||
|
|
||||||
@ -29,7 +33,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_service(hass, config, discovery_info=None):
|
def get_service(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> JoinNotificationService | None:
|
||||||
"""Get the Join notification service."""
|
"""Get the Join notification service."""
|
||||||
api_key = config.get(CONF_API_KEY)
|
api_key = config.get(CONF_API_KEY)
|
||||||
device_id = config.get(CONF_DEVICE_ID)
|
device_id = config.get(CONF_DEVICE_ID)
|
||||||
@ -37,13 +45,13 @@ def get_service(hass, config, discovery_info=None):
|
|||||||
device_names = config.get(CONF_DEVICE_NAMES)
|
device_names = config.get(CONF_DEVICE_NAMES)
|
||||||
if api_key and not get_devices(api_key):
|
if api_key and not get_devices(api_key):
|
||||||
_LOGGER.error("Error connecting to Join. Check the API key")
|
_LOGGER.error("Error connecting to Join. Check the API key")
|
||||||
return False
|
return None
|
||||||
if device_id is None and device_ids is None and device_names is None:
|
if device_id is None and device_ids is None and device_names is None:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"No device was provided. Please specify device_id"
|
"No device was provided. Please specify device_id"
|
||||||
", device_ids, or device_names"
|
", device_ids, or device_names"
|
||||||
)
|
)
|
||||||
return False
|
return None
|
||||||
return JoinNotificationService(api_key, device_id, device_ids, device_names)
|
return JoinNotificationService(api_key, device_id, device_ids, device_names)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user