You are currently viewing the Homey Apps SDK v2 documentation. New apps should use Homey Apps SDK v3 ››

Homey.BlePeripheral

const { BlePeripheral } = require('homey');

This class is a representation of a BLE peripheral in Homey. This class must not be initiated by the developer, but retrieved by calling BleAdvertisement#connect.

Table of Contents

Constructor

new Homey.BlePeripheral()

Properties:
Name Type Description
id string

Id of the peripheral assigned by Homey

uuid string

Uuid of the peripheral

address string

The mac address of the peripheral

addressType string

The address type of the peripheral

connectable boolean

Indicates if Homey can connect to the peripheral

rssi number

The rssi signal strength value for the peripheral

state string

The state of the peripheral

isConnected boolean

If the peripheral is currently connected to Homey

services Array.<BleService>

Array of services of the peripheral. Note that this array is only filled after the service is discovered by {BleAdvertisement#discoverServices} or {BleAdvertisement#discoverService}

advertisement BlePeripheral#Advertisement

Advertisement data of the peripheral

Methods

(async) assertConnected() → {Promise}

Asserts that the device is connected and if not, connects with the device.

Returns:
Type:
Promise

(async) connect() → {BlePeripheral}

Connects to the peripheral if Homey disconnected from it

Returns:
Type:
BlePeripheral

(async) disconnect() → {Promise}

Disconnect Homey from the peripheral

Returns:
Type:
Promise

(async) discoverAllServicesAndCharacteristics() → {Array.<BleService>}

Discovers all services and characteristics of the peripheral

Returns:
Type:
Array.<BleService>

(async) discoverServices(servicesFilteropt) → {Array.<BleService>}

Discovers the services of the peripheral

Parameters:
Name Type Attributes Description
servicesFilter Array.<string> <optional>

list of services to discover, if not given all services will be discovered

Returns:
Type:
Array.<BleService>

(async) getService(uuid) → {BleService}

Get a service with the given uuid

Parameters:
Name Type Description
uuid string

The uuid of the service

Returns:
Type:
BleService

(async) read(serviceUuid, characteristicUuid) → {Buffer}

Shorthand to read a characteristic for given serviceUuid and characteristicUuid

Parameters:
Name Type Description
serviceUuid string

The uuid of the service that has given characteristic

characteristicUuid string

The uuid of the characteristic that needs to be read

Returns:
Type:
Buffer

(async) updateRssi() → {string}

Updates the RSSI signal strength value

Returns:
Type:
string

rssi

(async) write(serviceUuid, characteristicUuid, data) → {Buffer}

Shorthand to write to a characteristic for given serviceUuid and characteristicUuid

Parameters:
Name Type Description
serviceUuid string

The uuid of the service that has given characteristic

characteristicUuid string

The uuid of the characteristic that needs to be written to

data Buffer

The data that needs to be written

Returns:
Type:
Buffer

Type Definitions

Properties:
Name Type Description
localName string

The local name of the peripheral

manufacturerData string

Manufacturer specific data for peripheral

serviceData Array.<string>

Array of service data entries

serviceUuids Array.<string>

Array of service uuids

Type:
  • Object