Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homey.createDevice() doesn't pass errors #330

Open
robertklep opened this issue Dec 30, 2023 · 1 comment
Open

Homey.createDevice() doesn't pass errors #330

robertklep opened this issue Dec 30, 2023 · 1 comment
Assignees

Comments

@robertklep
Copy link

If Homey.createDevice() fails (for instance, when trying to add a device with an id that already exists), an error is shown on screen but the call to the method returns without any clue that it failed (no exception thrown, no undefined returned, no error passed when using callbacks).

@dskantz
Copy link

dskantz commented Dec 31, 2023

Adding some details here:

In a custom Pair View I have the following script:

<script type="text/javascript">
  (function () {
    const $create = document.getElementById("receiver-add-create");
    let creatingDevice = false;

    $create.addEventListener("click", (e) => {
      if (creatingDevice) return;
      creatingDevice = true;
      
       ... 

      Homey.createDevice(device)
        .then(function () {
          return Homey.done();
        })
        .catch(function (err) {
          creatingDevice = false;
          return Homey.Alert(
            "There is already a device with that House Code and Unit Code combination."
          );
        });
    });
  })();
</script> 

EXPECTED: Display an alert if any error happens and if Home.createDevice() is successful paring window will be closed.

ACTUAL WEB APP (Chrome and Edge): Regardless of outcome from Homey.createDevice then() is called, catch() is never called on errors, and if an error occurs Homey will display an error toast I cannot get rid of.

ACTUAL IPHONE APP: When not failing, the then() call is made, but catch() is not called when it fails.

So it seems like in Edge or Chome in the Web App, catch() is never called, then() is always called.
In the IPhone App, catch() is never called, then() is only called on success.

@jeroenwienk jeroenwienk self-assigned this Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants