custom#

class platypush.message.event.custom.CustomEvent(subtype: str, *args, **kwargs)[source]#

Bases: Event

This type can be used to fire custom events upon which the user can implement custom hooks.

__init__(subtype: str, *args, **kwargs)[source]#
Parameters:
  • subtype – This is the only mandatory attribute for this event type. It should be a string that unambiguously identifies a certain type of event (like DISHWASHER_STARTED or SMOKE_DETECTED).

  • args – Extra list arguments for the event.

  • kwargs – Extra key-value arguments for the event.

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