Loading

This view will show a loading indicator. It's usually useful to show this view when an asynchronous operation needs to be made.

Usage: "template": "loading"

/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": "loading" }
    },
    {
      "id": "loading",
      "template": "loading"
    },
    {
      "id": "add_devices",
      "template": "add_devices"
    }
  ]
}
/drivers/<driver_id>/driver.js
const Homey = require("homey");
const DeviceAPI = require("device-api");

class Driver extends Homey.Driver {
  onPair(session) {
    session.setHandler("list_devices", async () => {
      return [
        {
          name: "My Device",
          data: {
            id: "abcd",
          },
        },
      ];
    });

    session.setHandler('showView', async (view) => {
      if (view === 'loading') {
        await DeviceAPI.connect();
        await session.nextView();
      }
    });
  }
}

module.exports = Driver;

Last updated