Pincode

This pair template shows a pincode input. When the pincode is correct, it will proceed to the next view.

Usage: "template": "pincode"

/drivers/<driver_id>/driver.compose.json
{
  "name": { "en": "My Driver" },
  "images": {
    "small": "/drivers/my_driver/assets/images/small.png",
    "large": "/drivers/my_driver/assets/images/large.png"
  },
  "pair": [
    {
      "id": "list_devices",
      "template": "list_devices",
      "navigation": { "next": "pincode" }
    },
    {
      "id": "pincode",
      "template": "pincode",
      "options": {
        "title": "Login with your account",
        "hint": "Enter the device's pincode",
        "type": "number",
        "length": 4
      }
    },
    {
      "id": "add_devices",
      "template": "add_devices"
    }
  ]
}

Options

Key

Type

Default

Description

type

string

"number"

Either number or text. This changes how the keyboard is presented on mobile phones when the pincode field is selected.

length

number

4

The number of characters

hint

""

title

"Enter pincode:"

/drivers/<driver_id>/driver.js
const Homey = require("homey");

class Driver extends Homey.Driver {
  onPair(session) {
    session.setHandler("pincode", async (pincode) => {
      // The pincode is given as an array of the filled in values
      return (
        pincode[0] === "1"
        && pincode[1] === "2" 
        && pincode[2] === "3"
        && pincode[3] === "4"
      );
    });
  }
}

module.exports = Driver;

Last updated