ntfy
#
Description#
Ntfy integration.
ntfy allows you to process asynchronous notification across multiple devices and it’s compatible with the UnifiedPush <https://unifiedpush.org/> specification.
Configuration#
ntfy:
# [Optional]
# Default ntfy instance base URL (default: ``https://ntfy.sh``).
# server_url: https://ntfy.sh # type=str
# [Optional]
# List of topics the plugin should subscribe to
# (default: none).
# subscriptions: # type=Optional[Collection[str]]
# [Optional]
# How often the `RunnablePlugin.loop <https://docs.platypush.tech/platypush/plugins/.html#platypush.plugins.RunnablePlugin.loop>`_ function should be
# executed (default: 15 seconds). *NOTE*: For back-compatibility
# reasons, the `poll_seconds` argument is also supported, but it's
# deprecated.
# poll_interval: 15 # type=Optional[float]
# [Optional]
# How long we should wait for any running
# threads/processes to stop before exiting (default: 5 seconds).
# stop_timeout: 5 # type=Optional[float]
# [Optional]
# If set to True then the plugin will not monitor
# for new events. This is useful if you want to run a plugin in
# stateless mode and only leverage its actions, without triggering any
# events. Defaults to False.
# disable_monitor: False # type=bool
Triggered events#
Actions#
Module reference#
- class platypush.plugins.ntfy.NtfyPlugin(server_url: str = 'https://ntfy.sh', subscriptions: Collection[str] | None = None, **kwargs)[source]#
Bases:
AsyncRunnablePlugin
Ntfy integration.
ntfy allows you to process asynchronous notification across multiple devices and it’s compatible with the UnifiedPush <https://unifiedpush.org/> specification.
- __init__(server_url: str = 'https://ntfy.sh', subscriptions: Collection[str] | None = 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).
- async listen()[source]#
Main body of the async plugin. When it’s called, the event loop should already be running and available over self._loop.
- main()#
Implementation of the main loop of the plugin.
- send_message(topic: str, message: str = '', server_url: str | None = None, username: str | None = None, password: str | None = None, title: str | None = None, url: str | None = None, attachment: str | None = None, filename: str | None = None, actions: Collection[Mapping[str, str]] | None = None, email: str | None = None, priority: str | None = None, tags: Collection[str] | None = None, schedule: str | None = 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, amailto:`, 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 clickedhttp
: 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).
Actions 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" } } ]
- Parameters:
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
ortomorrow, 3pm
)
- start()#
Start the plugin.
- stop()#
Stop the plugin.
- wait_stop(timeout=None)#
Wait until a stop event is received.