Homey Community Forum

Devices search

hello everyone,
I am new here actually and i was working of an app to communicate with eWelink supported devices but locally. I tested the concept and it works, my problem is with Homey app development i cant get it to to search for devices like any other app. when i installed it to add the devices which i created driver for it shows that there’s no devices listed. below is the driver.js code

‘use strict’;

const Homey = require(‘homey’);
const ewelink = require(‘ewelink-api’);
const {ManagerDrivers} = require(‘homey’);

module.exports = class S26Driver extends Homey.Driver {

async device_cash(email, password) {
	const connection = new ewelink({ email, password });
	const cash_file = await connection.getDevices();
	let results = [];
	for(var i = 0; i < cash_file.length; i++){
		if(cash_file[i]["productModel"] == 'TX3C'){
			// this.log(cash_file[i])
			results = (cash_file[i]);
	// this.log("results", results);
	return results;

onPairListDevices() {

    const devices = await this.device_cash();
    const pairs = ManagerDrivers.getDrivers();

async onInit() {
    this.log('MyDriver has been inited');
	// this.log(devices);


You don’t have to call onPairListDevices manually, it will be called automatically. When you have gathered all the discovered devices, you need to call the passed-in callback with your list:

async onPairListDevices(data, callback) {
  callback(null, await this.device_cash());

Documented (somewhat) here: https://developer.athom.com/docs/apps/tutorial-Drivers-Pairing-System%20Views-Devices%20List.html

By the way, this doesn’t do what you think it does:

results = (cash_file[i]);

results is declared an array, but you’re setting it to an object in the above line, so device_cash actually returns an object, not an array. That may also break onPairListDevices because (AFAIK) the callback requires an array.

Thanks a lot, robertklep,
i guess i missed that
i have an error regarding the callback function

async onPairListDevices(data, callback) {
const connection = new ewelink({
email, password,
region: ‘eu’,

	callback(null, await connection.getDevices());
	// this.log("smart", devices);

TypeError: callback is not a function

You might want to get some information in your message removed (like the password), it’s a security issue.


Are you sure you’re not still calling this.onPairListDevices() from onInit()?

What does this.log( await connection.getDevices() ) show?

settings: {
opsNotify: 0,
opsHistory: 1,
alarmNotify: 1,
wxAlarmNotify: 0,
wxOpsNotify: 0,
wxDoorbellNotify: 0,
appDoorbellNotify: 1
family: { room: [Object], id: ‘5ed5fe75c38b630008558b8c’, index: -2 },
group: ‘’,
online: false,
shareUsersInfo: [ [Object] ],
groups: ,
devGroups: ,
_id: ‘’,
deviceid: ‘’,
name: ‘My Room’,
type: ‘10’,
apikey: ‘386c-4432-836c-f891e9c0ed07’,
extra: { extra: [Object], _id: ‘5d4bd9d9b9fe4f5’ },
createdAt: ‘2020-06-02T18:34:00.236Z’,
__v: 0,
onlineTime: ‘2020-06-18T00:39:50.977Z’,
params: {
version: 8,
sledOnline: ‘on’,
fwVersion: ‘3.4.0’,
staMac: ‘D8:F1:5B:8D:F3:F7’,
rssi: -55,
init: 1,
lock: 0,
configure: [Array],
pulses: [Array],
switches: [Array],
timers: [Array]
ip: ‘197.xx.xx.xxx’,
location: ‘’,
tags: { },
offlineTime: ‘2020-06-18T09:00:10.235Z’,
sharedBy: {
email: ‘’,
apikey: ‘’,
permit: 15,
shareTime: 1591867892792

it prints device cash like this above

Perhaps you should start with creating a simpler app, just to get an idea how apps (and drivers, and devices) work in general.