Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
1 change: 1 addition & 0 deletions homeassistant/components/cisco_webex_teams/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Component to integrate the Cisco Webex Teams cloud."""
53 changes: 53 additions & 0 deletions homeassistant/components/cisco_webex_teams/notify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Cisco Webex Teams notify component."""
import logging

import voluptuous as vol

from homeassistant.components.notify import (
PLATFORM_SCHEMA, BaseNotificationService, ATTR_TITLE)
from homeassistant.const import (CONF_TOKEN)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['webexteamssdk==1.1.1']

_LOGGER = logging.getLogger(__name__)

CONF_ROOMID = 'room_id'
Comment thread
fbradyirl marked this conversation as resolved.
Outdated

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_TOKEN): cv.string,
vol.Required(CONF_ROOMID): cv.string,
})


def get_service(hass, config, discovery_info=None):
"""Get the CiscoWebexTeams notification service."""
return CiscoWebexTeamsNotificationService(
config[CONF_TOKEN],
config[CONF_ROOMID])


class CiscoWebexTeamsNotificationService(BaseNotificationService):
"""The Cisco Webex Teams Notification Service."""

def __init__(self, token, room):
"""Initialize the service."""
from webexteamssdk import WebexTeamsAPI
self.room = room
self.client = WebexTeamsAPI(access_token=token)
Comment thread
fbradyirl marked this conversation as resolved.
Outdated
[room for room in self.client.rooms.list()]
Comment thread
fbradyirl marked this conversation as resolved.
Outdated

def send_message(self, message="", **kwargs):
"""Send a message to a user."""
from webexteamssdk import ApiError
try:
title = ""
if kwargs.get(ATTR_TITLE) is not None:
title = "{}{}".format(kwargs.get(ATTR_TITLE), "<br>")
Comment thread
fbradyirl marked this conversation as resolved.
Outdated
self.client.messages.create(
roomId=self.room,
html="{}{}".format(title, message))
except ApiError as api_error:
_LOGGER.error("Could not send CiscoWebexTeams notification. "
"Error: %s",
api_error)
6 changes: 3 additions & 3 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,6 @@ caldav==0.5.0
# homeassistant.components.cisco_mobility_express.device_tracker
ciscomobilityexpress==0.1.5

# homeassistant.components.ciscospark.notify
ciscosparkapi==0.4.2

# homeassistant.components.cppm_tracker.device_tracker
clearpasspy==1.0.2

Expand Down Expand Up @@ -1783,6 +1780,9 @@ watchdog==0.8.3
# homeassistant.components.waterfurnace
waterfurnace==1.1.0

# homeassistant.components.cisco_webex_teams.notify
webexteamssdk==1.1.1

# homeassistant.components.gpmdp.media_player
websocket-client==0.54.0

Expand Down