PairSession.showView() and other not work

I tried showView() and other methods in onPair().
And they do absolutely nothing, they are just ignored, with or without await. Writing in TypeScript, and adding comments like //@ts-ignore

The only option that worked for me was Homey.emit() from View.html to onPair() to make some checks and Callback result to View.html to make a Homey.showView()

Code or it didn’t happen.

2 Likes

Something like this. Even async/await don’t work. Also while making pair.emit(""), it not emit and not send it to View.html. In general, not a single pair command does not work, They only works in View.html

onPair(pair: Homey.Driver.PairSession) {
        //@ts-ignore
        pair.showView("list_devices");
    }

The only method I have for bypassing broken commands is this:

In onPair():

pair.setHandler("check", async () => {
            return await this.session.checkAuth();
        });

        pair.setHandler("start", async () => {
            return !this.session.ready ? await this.session.getAuthUrl() : "list_devices";
        });

In auth.html

<script type="application/javascript">
    Homey.emit("start").then((view => {
        if (view === "list_devices") {
            Homey.showView(view);
        } else {
            Homey.setTitle("Авторизация");
            document.getElementById("wrapper").style.display = "flex";
            document.getElementById("ya-button").href = view;

            let check = setInterval(() => {
                Homey.emit("check").then((result) => {
                    if (result) {
                        clearInterval(check);
                        Homey.showView("list_devices");
                    }
                });
            }, 5000);
        }
    }));
</script>

Well yes, obviously, but of course we need more context if you want help. For instance, how have you configured your pairing steps in app.json?

FWIW, I don’t know why the TS declarations are missing basically all methods, I’ll post an issue on Github.

driver.compose.json → pair

"pair": [
        {
            "id": "auth"
        },
        {
            "id": "list_devices",
            "template": "list_devices",
            "navigation": { "next": "add_devices" }
        },
        {
            "id": "add_devices",
            "template": "add_devices"
        }
    ]

File
CleanShot 2022-02-26 at 00.21.17@2x

setHandler is the only one that works in onPair()

Regardless of whether the other methods are declared or not, they should work. Are you sure your HTML page isn’t erroring out on something? If you’re not already doing so, run the pairing process from the developer website and keep your browser’s developer tools/console open.

I checked absolutely everything, including the console.

Do you have the code of your app on Github?

Your issue isn’t with showView() not working, but with the way you want to handle authentication:

You can’t forward users to websites for authentication like that. As far as I know, you need to either use the OAuth2 or the Credentials Login views (it doesn’t look like Yandex is using OAuth2), or provide an alternative that doesn’t require directing the user to an external website.