ntfy

ntfy

class platypush.plugins.ntfy.NtfyPlugin(server_url: str = 'https://ntfy.sh', subscriptions: Optional[Collection[str]] = None, **kwargs)[source]

Ntfy integration.

ntfy allows you to process asynchronous notification across multiple devices and it’s compatible with the UnifiedPush <https://unifiedpush.org/> specification.

Triggers:

__init__(server_url: str = 'https://ntfy.sh', subscriptions: Optional[Collection[str]] = None, **kwargs)[source]
Parameters:
  • server_url – Default ntfy instance base URL (default: https://ntfy.sh).

  • subscriptions – List of topics the plugin should subscribe to (default: none).

send_message(topic: str, message: str = '', server_url: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, title: Optional[str] = None, url: Optional[str] = None, attachment: Optional[str] = None, filename: Optional[str] = None, actions: Optional[Collection[Mapping[str, str]]] = None, email: Optional[str] = None, priority: Optional[str] = None, tags: Optional[Collection[str]] = None, schedule: Optional[str] = None)[source]

Send a message/notification to a topic.

Parameters:
  • topic – Topic where the message will be delivered.

  • message – Text of the message to be sent.

  • server_url – Override the default server URL.

  • username – Set if publishing to the topic requires authentication

  • password – Set if publishing to the topic requires authentication

  • title – Custom notification title.

  • url – URL that should be opened when the user clicks the notification. It can be an http(s):// URL, a mailto:`, a ``geo:, a link to another ntfy topic (e.g. ntfy://mytopic) or a Twitter link (e.g. twitter://user?screen_name=myname).

  • attachment – Attach a file or URL to the notification. It can either be an HTTP URL or a path to a local file.

  • filename – If attachment is specified, you can override the output filename (default: same filename as the URL/path base name).

  • actions

    List of objects describing possible action buttons available for the notification. Supported types:

    • view: Open a URL or an app when the action button is clicked

    • http: Send an HTTP request upon action selection.

    • broadcast: Send an Android broadcast <https://developer.android.com/guide/components/broadcasts>

      intent upon action selection (only available on Android).

    Example:

    [
        {
            "action": "view",
            "label": "Open portal",
            "url": "https://home.nest.com/",
            "clear": true
        },
        {
            "action": "http",
            "label": "Turn down",
            "url": "https://api.nest.com/",
            "method": "PUT",
            "headers": {
                "Authorization": "Bearer abcdef..."
            },
            "body": "{\"temperature\": 65}"
        },
        {
            "action": "broadcast",
            "label": "Take picture",
            "intent": "com.myapp.TAKE_PICTURE_INTENT",
            "extras": {
                "camera": "front"
            }
        }
    ]
    

  • email – Forward the notification as an email to the specified address.

  • priority – Custom notification priority. Supported values: [max, high, default, low, min].

  • tags – Optional list of tags associated with the notification. Tag names that match emoji short codes will be rendered as emojis in the notification - see here <https://ntfy.sh/docs/emojis/> for a list of supported emojis.

  • schedule

    Schedule the message to be delivered at a specific time (for example, for reminders). Supported formats:

    • UNIX timestamps

    • Duration (e.g. 30m, 3h, 2 days)

    • Natural language strings (e.g. Tuesday, 7am or tomorrow, 3pm)