# Pincode

**Usage:** `"template": "pincode"`

<figure><img src="/files/uyQ6uQkfzcgThf33chf2" alt=""><figcaption></figcaption></figure>

{% code title="/drivers/\<driver\_id>/driver.compose.json" %}

```javascript
{
  "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"
    }
  ]
}
```

{% endcode %}

## **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`   | [translation object](/the-basics/app/internationalization.md) | `""`               |                                                                                                                            |
| `title`  | [translation object](/the-basics/app/internationalization.md) | `"Enter pincode:"` |                                                                                                                            |

{% tabs %}
{% tab title="JavaScript" %}
{% code title="/drivers/\<driver\_id>/driver.js" %}

```javascript
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;
```

{% endcode %}
{% endtab %}

{% tab title="TypeScript" %}
{% code title="/drivers/\<driver\_id>/driver.mts" %}

```mts
import Homey from "homey";

export default class Driver extends Homey.Driver {
  async onPair(session: Homey.Driver.PairSession): Promise<void> {
    session.setHandler("pincode", async (pincode: string[]): Promise<boolean> => {
      // 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"
      );
    });
  }
}

```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code title="/drivers/\<driver\_id>/driver.py" %}

```python
from homey import driver
from homey.pair_session import PairSession


class Driver(driver.Driver):
    async def on_pair(self, session: PairSession) -> None:
        async def on_pincode(pincode: list[str]) -> bool:
            # The pincode is given as an array of the filled in values
            return (
                pincode[0] == "1"
                and pincode[1] == "2"
                and pincode[2] == "3"
                and pincode[3] == "4"
            )


homey_export = Driver

```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apps.developer.homey.app/the-basics/devices/pairing/system-views/pincode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
