1 """Support for Join notifications."""
3 from __future__
import annotations
7 from pyjoin
import get_devices, send_notification
8 import voluptuous
as vol
14 PLATFORM_SCHEMA
as NOTIFY_PLATFORM_SCHEMA,
15 BaseNotificationService,
22 _LOGGER = logging.getLogger(__name__)
24 CONF_DEVICE_IDS =
"device_ids"
25 CONF_DEVICE_NAMES =
"device_names"
27 PLATFORM_SCHEMA = NOTIFY_PLATFORM_SCHEMA.extend(
29 vol.Required(CONF_API_KEY): cv.string,
30 vol.Optional(CONF_DEVICE_ID): cv.string,
31 vol.Optional(CONF_DEVICE_IDS): cv.string,
32 vol.Optional(CONF_DEVICE_NAMES): cv.string,
40 discovery_info: DiscoveryInfoType |
None =
None,
41 ) -> JoinNotificationService |
None:
42 """Get the Join notification service."""
43 api_key = config.get(CONF_API_KEY)
44 device_id = config.get(CONF_DEVICE_ID)
45 device_ids = config.get(CONF_DEVICE_IDS)
46 device_names = config.get(CONF_DEVICE_NAMES)
47 if api_key
and not get_devices(api_key):
48 _LOGGER.error(
"Error connecting to Join. Check the API key")
50 if device_id
is None and device_ids
is None and device_names
is None:
52 "No device was provided. Please specify device_id"
53 ", device_ids, or device_names"
60 """Implement the notification service for Join."""
62 def __init__(self, api_key, device_id, device_ids, device_names):
63 """Initialize the service."""
70 """Send a message to a user."""
71 title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
72 data = kwargs.get(ATTR_DATA)
or {}
79 icon=data.get(
"icon"),
80 smallicon=data.get(
"smallicon"),
81 image=data.get(
"image"),
82 sound=data.get(
"sound"),
83 notification_id=data.get(
"notification_id"),
84 category=data.get(
"category"),
87 tts_language=data.get(
"tts_language"),
88 vibration=data.get(
"vibration"),
89 actions=data.get(
"actions"),
def __init__(self, api_key, device_id, device_ids, device_names)
def send_message(self, message="", **kwargs)
JoinNotificationService|None get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)