cellcortex / homebridge-yeelighter

Homebridge plugin for Yeelights - special focus on supporting features of ceiling lights
MIT License
98 stars 20 forks source link

TypeError: Cannot read properties of undefined (reading 'split') #127

Closed sdtaheri closed 1 year ago

sdtaheri commented 2 years ago

Hi. This is the log I'm getting when homebridge starts.

[11/1/2022, 6:28:43 PM] [Yeelighter] Initializing Yeelighter platform...
[11/1/2022, 6:28:43 PM] [Yeelighter] adding 1 manual accessories
[11/1/2022, 6:28:43 PM] [Yeelighter] New yeelink.light.strip1 [0x000000000361af90] found at yeelight://10.136.1.32
[11/1/2022, 6:28:43 PM] [Yeelighter] Loading accessory from cache: 0x000000000361af90 (yeelink.light.strip1)
[11/1/2022, 6:28:43 PM] [Yeelighter] Accessory created with UUID e60cbbd2-719a-4acd-9130-077f1c0b7805
[11/1/2022, 6:28:43 PM] [Yeelighter] Device discovery handling failed TypeError: Cannot read properties of undefined (reading 'split')
    at new YeeAccessory (/usr/local/lib/node_modules/homebridge-yeelighter/dist/yeeaccessory.js:212:44)
    at Function.instance (/usr/local/lib/node_modules/homebridge-yeelighter/dist/yeeaccessory.js:291:19)
    at YeelighterPlatform.onDeviceDiscovery (/usr/local/lib/node_modules/homebridge-yeelighter/dist/platform.js:156:49)
    at YeelighterPlatform.addHardCodedAccessories (/usr/local/lib/node_modules/homebridge-yeelighter/dist/platform.js:205:18)
    at HomebridgeAPI.<anonymous> (/usr/local/lib/node_modules/homebridge-yeelighter/dist/platform.js:178:18)
    at HomebridgeAPI.emit (node:events:513:28)
    at HomebridgeAPI.signalFinished (/usr/local/lib/node_modules/homebridge/lib/api.js:89:14)
    at Server.start (/usr/local/lib/node_modules/homebridge/lib/server.js:138:18)

This is the config for Yeeligher:

{
    "name": "Yeelighter",
    "timeout": 5000,
    "interval": 60000,
    "ctforcolor": true,
    "blocking": false,
    "split": false,
    "manual": [
        {
            "id": "0x000000000361af90",
            "address": "10.136.1.32",
            "name": "TV Lightstrip",
            "model": "yeelink.light.strip1"
        }
    ],
    "platform": "Yeelighter"
}

My setup environment:

Hombridge: v1.5.1 Node.js: v18.12.0 OS: Linux raspberrypi 5.15.74-v7l+

It doesn't work either if I don't add the manual key.

I'd appreciate if you could help me find the issue.

Idomo commented 1 year ago

This error happens because of device.support is undefined on this line. It should be changed to:

const support = deviceInfo.support?.split(" ") || "";

Yet, it seems like device.support should never be undefined since after fixing it you'll run into issue #69, that means something in much earlier step has been going wrong...

cellcortex commented 1 year ago

I put some extra logging in for these corrupt device info. However if you have these, it might be best to remove these devices from the home bridge cache. With the deviceInfo missing, there won't be much that yeelighter can do with these devices.