athombv / homey-web-api-issues

This issue tracker is for Homey Developers using the Web API.
4 stars 1 forks source link

device.capabilitiesObj returns null while device is ready. #16

Closed daneedk closed 3 months ago

daneedk commented 2 years ago

Since the release of Homey firmware v7.4.1, the Heimdall app is regularly crashing because of this error:

TypeError: Cannot use 'in' operator to search for 'alarm_motion' in null at Heimdall.checkDeviceState (/app.js:831:29) at Heimdall.checkDevicesState (/app.js:818:18) at processTicksAndRejections (node:internal/process/task_queues:96:5)

This is the relevant code:

image-7

As you can see on line 826 there is a check if the device is ready. I would assumed the device.capabilitiesObj would return {} and not null. I've reported this on Slack, Jeroen Wink asked me to report it here.

For now I've 'fixed' this by replacing line 826 with line 827:

image

(btw. there is an older issue opened bij Robert Klep that may be related: https://github.com/athombv/homey-web-api-issues/issues/3)

WeeJeWel commented 3 months ago

Device Update events may come in separately so the correct way is to always check if capabilitiesObj actually is an object, e.g. device.capabilitiesObj?.onoff.