constHomey=require("homey");constDeviceAPI=require("device-api");classDriverextendsHomey.Driver {asynconPair(session) {let username ="";let password ="";session.setHandler("login",async (data) => { username =data.username; password =data.password;constcredentialsAreValid=awaitDeviceAPI.testCredentials({ username, password, });// return true to continue adding the device if the login succeeded// return false to indicate to the user the login attempt failed// thrown errors will also be shown to the userreturn credentialsAreValid; });session.setHandler("list_devices",async () => {constapi=awaitDeviceAPI.login({ username, password });constmyDevices=awaitapi.getDevices();constdevices=myDevices.map((myDevice) => {return { name:myDevice.name, data: { id:myDevice.id, }, settings: {// Store username & password in settings// so the user can change them later username, password, }, }; });return devices; }); }}module.exports= Driver;