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

/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