1 """Cisco Webex notify component."""
3 from __future__
import annotations
7 import voluptuous
as vol
8 from webexpythonsdk
import ApiError, WebexAPI, exceptions
12 PLATFORM_SCHEMA
as NOTIFY_PLATFORM_SCHEMA,
13 BaseNotificationService,
20 _LOGGER = logging.getLogger(__name__)
22 CONF_ROOM_ID =
"room_id"
24 PLATFORM_SCHEMA = NOTIFY_PLATFORM_SCHEMA.extend(
25 {vol.Required(CONF_TOKEN): cv.string, vol.Required(CONF_ROOM_ID): cv.string}
32 discovery_info: DiscoveryInfoType |
None =
None,
33 ) -> CiscoWebexNotificationService |
None:
34 """Get the Cisco Webex notification service."""
35 client = WebexAPI(access_token=config[CONF_TOKEN])
38 client.rooms.get(config[CONF_ROOM_ID])
39 except exceptions.ApiError
as error:
47 """The Cisco Webex Notification Service."""
50 """Initialize the service."""
55 """Send a message to a user."""
58 if kwargs.get(ATTR_TITLE)
is not None:
59 title = f
"{kwargs.get(ATTR_TITLE)}<br>"
62 self.
clientclient.messages.create(roomId=self.
roomroom, html=f
"{title}{message}")
63 except ApiError
as api_error:
65 "Could not send Cisco Webex notification. Error: %s", api_error
def send_message(self, message="", **kwargs)
def __init__(self, client, room)
CiscoWebexNotificationService|None get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)