ntfy
#
- class platypush.message.event.ntfy.NotificationEvent(*args, id: str, topic: str, message: str, title: str | None = None, priority: int | None = None, time: int | None = None, attachment: Mapping | None = None, actions: Collection[Mapping] | None = None, tags: Collection[str] | None = None, url: str | None = None, **kwargs)[source]#
Bases:
Event
Event triggered when a message/notification is received on a subscribed channel.
- __init__(*args, id: str, topic: str, message: str, title: str | None = None, priority: int | None = None, time: int | None = None, attachment: Mapping | None = None, actions: Collection[Mapping] | None = None, tags: Collection[str] | None = None, url: str | None = None, **kwargs)[source]#
- Parameters:
id – Message ID.
topic – The topic where the message was received.
message – Message body.
title – Message title.
priority – Message priority.
time – Message UNIX timestamp.
tags – Notification tags.
url – URL spawned when the notification is clicked.
actions –
List of actions associated to the notification. 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" } } ]
attachment –
Attachment metadata. Example:
{ "name": "image.jpg", "type": "image/jpeg", "size": 30017, "expires": 1654144935, "url": "https://ntfy.example.com/file/01234abcd.jpg" }
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object