bluetooth

Platypush documentation

bluetooth#

class platypush.message.event.bluetooth.BluetoothConnectionFailedEvent(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)[source]#

Bases: BluetoothDeviceEvent

Event triggered when a Bluetooth connection fails.

__init__(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothDeviceConnectedEvent(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)[source]#

Bases: BluetoothDeviceEvent

Event triggered when a Bluetooth device is connected.

__init__(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothDeviceDisconnectedEvent(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)[source]#

Bases: BluetoothDeviceEvent

Event triggered when a Bluetooth device is disconnected.

__init__(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothDeviceEvent(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)[source]#

Bases: BluetoothEvent

Base class for Bluetooth device events.

__init__(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)[source]#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent[source]#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothDeviceFoundEvent(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)[source]#

Bases: BluetoothDeviceEvent

Event triggered when a Bluetooth device is discovered during a scan.

__init__(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothDeviceLostEvent(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)[source]#

Bases: BluetoothDeviceEvent

Event triggered when a previously discovered Bluetooth device is lost.

__init__(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothDeviceSignalUpdateEvent(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)[source]#

Bases: BluetoothDeviceEvent

Event triggered when the RSSI/TX power of a Bluetooth device is updated.

__init__(*args, address: str, connected: bool, name: str | None = None, rssi: int | None = None, tx_power: int | None = None, manufacturer: str | None = None, services: Iterable[dict] | None = None, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothEvent(target=None, origin=None, id=None, timestamp=None, logging_level=20, disable_web_clients_notification=False, **kwargs)[source]#

Bases: Event

Base class for Bluetooth events.

__init__(target=None, origin=None, id=None, timestamp=None, logging_level=20, disable_web_clients_notification=False, **kwargs)#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional 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

class platypush.message.event.bluetooth.BluetoothFileEvent(*args, file: str, **kwargs)[source]#

Bases: BluetoothDeviceEvent

Base class for Bluetooth file events.

__init__(*args, file: str, **kwargs)[source]#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothFileGetRequestEvent(*args, file: str, **kwargs)[source]#

Bases: BluetoothFileEvent

Event triggered when a file get request is received.

__init__(*args, file: str, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothFilePutRequestEvent(*args, file: str, **kwargs)[source]#

Bases: BluetoothFileEvent

Event triggered when a file put request is received.

__init__(*args, file: str, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothFileReceivedEvent(*args, file: str, **kwargs)[source]#

Bases: BluetoothFileEvent

Event triggered when a file download is completed.

__init__(*args, file: str, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothFileSentEvent(*args, file: str, **kwargs)[source]#

Bases: BluetoothFileEvent

Event triggered when a file upload is completed.

__init__(*args, file: str, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothFileTransferCancelledEvent(*args, file: str, **kwargs)[source]#

Bases: BluetoothFileEvent

Event triggered when a file transfer is cancelled.

__init__(*args, file: str, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothFileTransferStartedEvent(*args, file: str, **kwargs)[source]#

Bases: BluetoothFileEvent

Event triggered when a file transfer is initiated.

__init__(*args, file: str, **kwargs)#
Parameters:
  • address – The Bluetooth address of the device.

  • connected – Whether the device is connected.

  • name – The name of the device.

  • rssi – Received Signal Strength Indicator.

  • tx_power – Transmission power.

  • manufacturers – The manufacturers published by the device, as a manufacturer_id -> registered_name map.

  • services – The services published by the device.

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

classmethod from_device(device: BluetoothDevice, **kwargs) BluetoothDeviceEvent#

Initialize a Bluetooth event from the parameters of a device.

Parameters:

device – Bluetooth device.

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

class platypush.message.event.bluetooth.BluetoothScanPausedEvent(*args, duration: float | None = None, **kwargs)[source]#

Bases: BluetoothEvent

Event triggered when the Bluetooth scan is paused.

__init__(*args, duration: float | None = None, **kwargs)[source]#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional 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

class platypush.message.event.bluetooth.BluetoothScanResumedEvent(*args, duration: float | None = None, **kwargs)[source]#

Bases: BluetoothEvent

Event triggered when the Bluetooth scan is resumed.

__init__(*args, duration: float | None = None, **kwargs)[source]#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional 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