Upgrade matrix-client to 0.3.2 (#30027)
This commit is contained in:
1 parent
115aa2e49c
commit
31cd0af47a
6 files changed
+30
-36
No files matched your search
@@ -11,32 +11,33 @@ from homeassistant.components.notify import (
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from .const import DOMAIN, SERVICE_SEND_MESSAGE
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_DEFAULT_ROOM = "default_room"
|
||||
|
||||
DOMAIN = "matrix"
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_DEFAULT_ROOM): cv.string})
|
||||
|
||||
|
||||
def get_service(hass, config, discovery_info=None):
|
||||
"""Get the Matrix notification service."""
|
||||
return MatrixNotificationService(config.get(CONF_DEFAULT_ROOM))
|
||||
return MatrixNotificationService(config[CONF_DEFAULT_ROOM])
|
||||
|
||||
|
||||
class MatrixNotificationService(BaseNotificationService):
|
||||
"""Send Notifications to a Matrix Room."""
|
||||
"""Send notifications to a Matrix room."""
|
||||
|
||||
def __init__(self, default_room):
|
||||
"""Set up the notification service."""
|
||||
"""Set up the Matrix notification service."""
|
||||
self._default_room = default_room
|
||||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send the message to the matrix server."""
|
||||
"""Send the message to the Matrix server."""
|
||||
target_rooms = kwargs.get(ATTR_TARGET) or [self._default_room]
|
||||
|
||||
service_data = {ATTR_TARGET: target_rooms, ATTR_MESSAGE: message}
|
||||
|
||||
return self.hass.services.call(
|
||||
DOMAIN, "send_message", service_data=service_data
|
||||
DOMAIN, SERVICE_SEND_MESSAGE, service_data=service_data
|
||||
)
|
||||
Reference in new issue
Block a user