Replace webexteamssdk with webexpythonsdk (#127928)

This commit is contained in:
DJ 2024-10-15 17:54:59 +02:00 committed by GitHub
parent 36a1eaedcf
commit aac5ac6057
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 13 deletions

View File

@ -1 +1 @@
"""Component to integrate the Cisco Webex Teams cloud.""" """Component to integrate the Cisco Webex cloud."""

View File

@ -2,9 +2,8 @@
"domain": "cisco_webex_teams", "domain": "cisco_webex_teams",
"name": "Cisco Webex Teams", "name": "Cisco Webex Teams",
"codeowners": ["@fbradyirl"], "codeowners": ["@fbradyirl"],
"disabled": "Integration library not compatible with Python 3.12",
"documentation": "https://www.home-assistant.io/integrations/cisco_webex_teams", "documentation": "https://www.home-assistant.io/integrations/cisco_webex_teams",
"iot_class": "cloud_push", "iot_class": "cloud_push",
"loggers": ["webexteamssdk"], "loggers": ["webexpythonsdk"],
"requirements": ["webexteamssdk==1.1.1;python_version<'3.12'"] "requirements": ["webexpythonsdk==2.0.1"]
} }

View File

@ -1,11 +1,11 @@
"""Cisco Webex Teams notify component.""" """Cisco Webex notify component."""
from __future__ import annotations from __future__ import annotations
import logging import logging
import voluptuous as vol import voluptuous as vol
from webexteamssdk import ApiError, WebexTeamsAPI, exceptions from webexpythonsdk import ApiError, WebexAPI, exceptions
from homeassistant.components.notify import ( from homeassistant.components.notify import (
ATTR_TITLE, ATTR_TITLE,
@ -30,9 +30,9 @@ def get_service(
hass: HomeAssistant, hass: HomeAssistant,
config: ConfigType, config: ConfigType,
discovery_info: DiscoveryInfoType | None = None, discovery_info: DiscoveryInfoType | None = None,
) -> CiscoWebexTeamsNotificationService | None: ) -> CiscoWebexNotificationService | None:
"""Get the CiscoWebexTeams notification service.""" """Get the Cisco Webex notification service."""
client = WebexTeamsAPI(access_token=config[CONF_TOKEN]) client = WebexAPI(access_token=config[CONF_TOKEN])
try: try:
# Validate the token & room_id # Validate the token & room_id
client.rooms.get(config[CONF_ROOM_ID]) client.rooms.get(config[CONF_ROOM_ID])
@ -40,11 +40,11 @@ def get_service(
_LOGGER.error(error) _LOGGER.error(error)
return None return None
return CiscoWebexTeamsNotificationService(client, config[CONF_ROOM_ID]) return CiscoWebexNotificationService(client, config[CONF_ROOM_ID])
class CiscoWebexTeamsNotificationService(BaseNotificationService): class CiscoWebexNotificationService(BaseNotificationService):
"""The Cisco Webex Teams Notification Service.""" """The Cisco Webex Notification Service."""
def __init__(self, client, room): def __init__(self, client, room):
"""Initialize the service.""" """Initialize the service."""
@ -62,5 +62,5 @@ class CiscoWebexTeamsNotificationService(BaseNotificationService):
self.client.messages.create(roomId=self.room, html=f"{title}{message}") self.client.messages.create(roomId=self.room, html=f"{title}{message}")
except ApiError as api_error: except ApiError as api_error:
_LOGGER.error( _LOGGER.error(
"Could not send CiscoWebexTeams notification. Error: %s", api_error "Could not send Cisco Webex notification. Error: %s", api_error
) )

View File

@ -2958,6 +2958,9 @@ waterfurnace==1.1.0
# homeassistant.components.weatherflow_cloud # homeassistant.components.weatherflow_cloud
weatherflow4py==1.0.6 weatherflow4py==1.0.6
# homeassistant.components.cisco_webex_teams
webexpythonsdk==2.0.1
# homeassistant.components.webmin # homeassistant.components.webmin
webmin-xmlrpc==0.0.2 webmin-xmlrpc==0.0.2