- Library:
Methods
getDevice(deviceData) → {Device}
Get a Device instance by its deviceData object.
Parameters:
Name | Type | Description |
---|---|---|
deviceData |
Object
|
Unique Device object as provided during pairing |
getDiscoveryStrategy() → {DiscoveryStrategy}
Get the driver's discovery strategy when defined in the manifest
Returns:
- Type:
-
DiscoveryStrategy
getManifest() → {Object}
Gets the driver's manifest (app.json entry)
Returns:
- Type:
-
Object
onInit()
This method is called when the driver is inited.
onMapDeviceClass(device)
When this method exists, it will be called prior to initing the device instance. Return a class that extends Device.
Parameters:
Name | Type | Description |
---|---|---|
device |
Device
|
A temporary Device instance to check certain properties before deciding which class the device should use. This class will exist for a single tick, and does not support async methods. |
Example
class MyDriver extends Homey.Driver {
onMapDeviceClass( device ) {
if( device.hasCapability('dim') ) {
return MyDeviceDim;
} else {
return MyDevice;
}
}
}
onPair(socket)
This method is called when a pair session starts.
Parameters:
Name | Type | Description |
---|---|---|
socket |
EventEmitter
|
Bi-directional socket for communication with the front-end |
onPairListDevices(data, callbackopt)
This method is called when no custom onPair() method has been defined, and the default is being used. Simple drivers should override this method to provide a list of devices ready to be paired.
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object
|
Empty object |
||||||||||
callback |
function
|
<optional> |
|
onRepair(socket, device)
This method is called when a repair session starts.
Parameters:
Name | Type | Description |
---|---|---|
socket |
EventEmitter
|
Bi-directional socket for communication with the front-end |
device |
Device
|
ready(callback)
Pass a callback method, which is called when the Driver is ready (Driver#onInit has been run). The callback is executed immediately when the Drivers Manager was already ready.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function
|