Error: Not Found: Device with ID xxx

For a a few months I am getting a lot of this errors: (a lot of emails)

I assume a device is deleted, but the app is still doing all the actions (capabilities, timers, etc.)

Error: Not Found: Device with ID ed2d613a-b697-4f21-84fb-2c6e2e814d97
at Remote Process
at HomeyClient.emit (/node_modules/@athombv/homey-apps-sdk-v3/lib/HomeyClient.js:44:23)
at Object.emit (/node_modules/@athombv/homey-apps-sdk-v3/manager/drivers.js:78:54)
at Object.emit (/node_modules/@athombv/homey-apps-sdk-v3/lib/Driver.js:126:50)
at /node_modules/@athombv/homey-apps-sdk-v3/lib/Device.js:570:27
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at Forecastsolardevice.setCapabilityValue (/node_modules/@athombv/homey-apps-sdk-v3/lib/Device.js:562:23)
at /app/drivers/forecastsolar/device.js:285:18
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

In my code I have added, but without success

onDeleted() {
clearTimeout(this.PollingTimeOut);
clearTimeout(this.StartPolling);
this.homey.clearInterval(this);
this.homey.clearTimeout(this);
this.log(‘forecastsolar has been deleted’);
}

You have some strange things in your code:

clearTimeout(this.PollingTimeOut);
this.PollingTimeOut();

You’re clearing a timeout that has the same name as a method? That can’t be right.

A timer is the result of a call to setTimeout/setInterval, and that’s what you need to clear:

this.PollingTimer = this.homey.setTimeout(...);
...
this.homey.clearTimeout(this.PollingTimer);

Also this:

clearTimeout(this.PollingTimeOut);
clearTimeout(this.StartPolling);
this.homey.clearInterval(this);
this.homey.clearTimeout(this);

You shouldn’t be using clearTimeout at all, only this.homey.clearTimeout (same for clearInterval).

1 Like