Pairing
Pairing allows users to add new devices to Homey.
Pairing is started when the user selects the device they want to add from the Homey app. The pair
property of the driver defines a list of views, which the user navigates through. These views are called pairing templates. Homey includes a set of system templates that implement consistent pairing steps for most devices.
Basic pairing example
This example is a basic way to enable pairing in your driver. To add pairing to your driver, add the following to your driver.compose.json
:
This defines a pairing process with 2 steps. The first step requires the user to pick the devices to add from a list and the second step will automatically add these devices to Homey. Both these steps use Homey's built-in pairing templates list_devices
and add_devices
. The navigation option determines which of the steps the pairing will go to when the user presses the "Next" button.
The navigation
object also supports a prev
option for when a user can go back to the previous screen. This can be useful, for example, with a login_credentials
system templates to allow users to retry logging-in.
If your pairing only uses the list_devices
and add_devices
templates you can use the Driver#onPairListDevices()
method to quickly implement a pairing process. From this method you can return a list of devices that will be presented to the user.
Device pairing data
The following is an overview of the data you can supply for a device to be added, you should return an array of objects like this from Driver#onPairListDevices()
or session.setHandler("list_devices")
.
System Views
The pairing templates are built with HTML, CSS and JavaScript. Most drivers will suffice using the system templates that are provided by Homey.
Custom Views
Most drivers will suffice using the provided templates. In certain cases you may want, or need, to create pairing screens that are more suited to your driver. For these cases it is possible to create custom pairing views, to learn more read the custom pairing view guide.
Repairing
To ensure users with a great experience, your app's devices should always stay available without user interaction.
However, sometimes when a device explicitly needs user interaction to be fixed (for example an OAuth2 token has been revoked and the user needs to authenticate again), the user can initiate a repair process.
To enable repairing, you must add support for this to your driver by adding repair
to your App Manifest:
It is also possible to use custom pairing views for repairing. To learn more about custom pairing templates read the custom pairing view guide.
Note that when repairing the Homey.createDevice()
method is not available in the custom view and you can add a onRepair
method to your driver, which is similar to the onPair
method.
Last updated