Ejemplo n.º 1
0
    def send_message(self, message='', **kwargs):
        """Send a message to a Simplepush user."""
        from simplepush import send, send_encrypted

        title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)

        if self._password:
            send_encrypted(self._device_key, self._password, self._salt, title,
                           message, event=self._event)
        else:
            send(self._device_key, title, message, event=self._event)
Ejemplo n.º 2
0
    def send_message(self, message='', **kwargs):
        """Send a message to a Simplepush user."""
        from simplepush import send, send_encrypted

        title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)

        if self._password:
            send_encrypted(self._device_key,
                           self._password,
                           self._salt,
                           title,
                           message,
                           event=self._event)
        else:
            send(self._device_key, title, message, event=self._event)
Ejemplo n.º 3
0
def validate_input(entry: dict[str, str]) -> dict[str, str] | None:
    """Validate user input."""
    try:
        if CONF_PASSWORD in entry:
            send_encrypted(
                entry[CONF_DEVICE_KEY],
                entry[CONF_PASSWORD],
                entry[CONF_PASSWORD],
                "HA test",
                "Message delivered successfully",
            )
        else:
            send(entry[CONF_DEVICE_KEY], "HA test",
                 "Message delivered successfully")
    except UnknownError:
        return {"base": "cannot_connect"}

    return None
Ejemplo n.º 4
0
class SimplePushNotificationService(BaseNotificationService):
    """Implementation of the notification service for Simplepush."""
    def __init__(self, config: dict[str, Any]) -> None:
        """Initialize the Simplepush notification service."""
        self._device_key: str = config[CONF_DEVICE_KEY]
        self._event: str | None = config.get(CONF_EVENT)
        self._password: str | None = config.get(CONF_PASSWORD)
        self._salt: str | None = config.get(CONF_SALT)

    def send_message(self, message: str, **kwargs: Any) -> None:
        """Send a message to a Simplepush user."""
        title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)

        # event can now be passed in the service data
        event = None
        if data := kwargs.get(ATTR_DATA):
            event = data.get(ATTR_EVENT)

        # use event from config until YAML config is removed
        event = event or self._event

        try:
            if self._password:
                send_encrypted(
                    self._device_key,
                    self._password,
                    self._salt,
                    title,
                    message,
                    event=event,
                )
            else:
                send(self._device_key, title, message, event=event)

        except BadRequest:
            _LOGGER.error("Bad request. Title or message are too long")
        except UnknownError:
            _LOGGER.error("Failed to send the notification")
Ejemplo n.º 5
0
def alert():
    ## use send_encrypted from simplepush to send an alert
    send_encrypted(key, password, salt, "Email", "New email")
Ejemplo n.º 6
0
def alert():
        ## use send_encrypted from simplepush to send an alert
        send_encrypted (key, password, salt, "Email", "New email")