-
-
Notifications
You must be signed in to change notification settings - Fork 38k
Rebrand Cisco Spark notify to be Cisco Webex Teams #21938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
92c93f8
Rebrand Cisco Spark notify to be Cisco Webex Teams
26752a7
Merge branch 'dev' of github.com:home-assistant/home-assistant into s…
540877b
Remove property from class
b1b5f03
Switch to use html for api
f5a3e76
Merge branch 'dev' into sparkRebrand
fbradyirl f523a17
Update notify.py
fbradyirl 76c1fa3
Merge branch 'dev' into sparkRebrand
fbradyirl b41e19b
Rename CONF_ROOMID to CONF_ROOM_ID
fbradyirl c7fae23
updated
fbradyirl 86fa202
Fix lint errors
fbradyirl aeed6ae
Update notify.py
fbradyirl edb4f6c
Update notify.py
fbradyirl 6801d66
Also validate room ID
fbradyirl 413fdfe
Update notify.py
fbradyirl 3111042
Update .coveragerc
fbradyirl 46996ed
Update notify.py
fbradyirl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Component to integrate the Cisco Webex Teams cloud.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| """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_ROOM_ID = 'room_id' | ||
|
|
||
| PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | ||
| vol.Required(CONF_TOKEN): cv.string, | ||
| vol.Required(CONF_ROOM_ID): cv.string, | ||
| }) | ||
|
|
||
|
|
||
| def get_service(hass, config, discovery_info=None): | ||
| """Get the CiscoWebexTeams notification service.""" | ||
| return CiscoWebexTeamsNotificationService( | ||
| config[CONF_TOKEN], | ||
| config[CONF_ROOM_ID]) | ||
|
|
||
|
|
||
| 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) | ||
| # List all rooms which validates the token | ||
| # pylint:disable=expression-not-assigned | ||
| [room for room in self.client.rooms.list()] | ||
|
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>") | ||
|
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) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.