# onPair session methods not working

**URL:** <https://community.homey.app/t/onpair-session-methods-not-working/66179>\
**Category:** Developers\
**Tags:** homey-pro\
**Created:** [July 17, 2022, 10:27pm UTC](https://community.homey.app/t/onpair-session-methods-not-working/66179 "2022-07-17T22:27:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhuan.barreto](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rhuan.barreto/32/42525_2.png) [@rhuan.barreto](https://community.homey.app/u/rhuan.barreto)\
**Post date:** [July 17, 2022, 10:27pm UTC](https://community.homey.app/t/onpair-session-methods-not-working/66179/1 "2022-07-17T22:27:47Z")

</div>

I’m trying to programmatically control the pairing flow if the app has already a setting. But it doesn’t work. Seems that `showView` and `nextView` are not implemented once the Typescript definitions are not in place and I must ignore them:

```auto
  async onPair(session: PairSession) {
    const pat = this.homey.settings.get("personalAccessToken");
    if (await this.validateSTToken(pat)) {
      this.log("Validated");
      // @ts-ignore
      await session.showView("list_devices");
      this.log("Page should change");
      // @ts-ignore
      await session.nextView();
      this.log("Nothing after the validate works");
    }

    session.setHandler("login_credentials", async (data) => {
      const valid = await this.validateSTToken(data.password);
      if (valid) this.homey.settings.set("personalAccessToken", data.password);
      return valid;
    });

    session.setHandler("list_devices", async () => {
      const myDevices = await this.client().devices.list({
        capability: this.capability,
      });
      const devices = myDevices?.map((device) => {
        const capabilities = getHomeyCapabilitiesForDevice(device);
        return {
          name: device.label ?? device.name,
          data: { id: device.deviceId },
          capabilities,
        };
      });

      return devices;
    });
  }

```

I’m using Homey Pro v8.0.2 and the homey-apps-sdk-v3-types library at 0.3.1

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 18, 2022, 4:47am UTC](https://community.homey.app/t/onpair-session-methods-not-working/66179/2 "2022-07-18T04:47:35Z")

</div>

Already posted an issue about this: [`PairSession` type declaration incomplete · Issue #8 · athombv/node-homey-apps-sdk-v3-types · GitHub](https://github.com/athombv/node-homey-apps-sdk-v3-types/issues/8)

But it was only posted 5 months ago, so it’s understandable it hasn’t been fixed yet /s

---

<div class="post-metadata">

**Author:** ![rhuan.barreto](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rhuan.barreto/32/42525_2.png) [@rhuan.barreto](https://community.homey.app/u/rhuan.barreto)\
**Post date:** [July 18, 2022, 12:02pm UTC](https://community.homey.app/t/onpair-session-methods-not-working/66179/3 "2022-07-18T12:02:10Z")

</div>

But what is not clear is that even ignoring typing it still doesn’t work. But it’s documented in their website [Custom pairing views - Homey Apps SDK](https://apps.developer.homey.app/advanced/custom-views/custom-pairing-views#back-end-api)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 18, 2022, 12:37pm UTC](https://community.homey.app/t/onpair-session-methods-not-working/66179/4 "2022-07-18T12:37:03Z")

</div>

Seems to work fine for me (at least `showView()` does, haven’t tested `nextView()`).

---

<div class="post-metadata">

**Author:** ![rhuan.barreto](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rhuan.barreto/32/42525_2.png) [@rhuan.barreto](https://community.homey.app/u/rhuan.barreto)\
**Post date:** [July 18, 2022, 1:07pm UTC](https://community.homey.app/t/onpair-session-methods-not-working/66179/5 "2022-07-18T13:07:43Z")

</div>

Am I doing something wrong on my code? I have the views defined in the driver and I just want to skip the first one if there’s already a setting saved.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 18, 2022, 1:13pm UTC](https://community.homey.app/t/onpair-session-methods-not-working/66179/6 "2022-07-18T13:13:50Z")

</div>

> [@rhuan.barreto](#):
>
> Am I doing something wrong on my code?

It doesn’t look like it, but how is your `app.json` configured, specifically the `pair` part of the driver?

---

<div class="post-metadata">

**Author:** ![rhuan.barreto](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rhuan.barreto/32/42525_2.png) [@rhuan.barreto](https://community.homey.app/u/rhuan.barreto)\
**Post date:** [July 24, 2022, 7:52am UTC](https://community.homey.app/t/onpair-session-methods-not-working/66179/7 "2022-07-24T07:52:02Z")

</div>

```auto
"pair": [
    {
      "id": "personal_token"
    },
    {
      "id": "list_devices",
      "template": "list_devices",
      "navigation": {
        "next": "add_devices"
      }
    },
    {
      "id": "add_devices",
      "template": "add_devices"
    }
  ],

```
