mirko3000 / MMM-xiaomi

Xiaomi smarthome plugin for the magic mirror
26 stars 3 forks source link

MMM-xiaomi/node_helper.js error: 'length' of undefined #12

Closed xuepgao closed 5 years ago

xuepgao commented 5 years ago

Hi guys,

I installed the module of MMM-xiaomi. I got the xiaomi gateway token via android emulator and https://miio.loli.ren. my config.js is as following:

        {
            module: 'MMM-xiaomi',
            position: 'top_right',
            header: 'Temperature / Humidity',
            config: {
                gatewayIP: '192.168.186.157',
                gatewayToken: 'xxxxxxxxxxd9e32a8373a409e651c333882',
                showWindow: true,
                showVentilation: true,
                showLights: false,
                audioNotifications: true,
                rooms: [
                    { name: 'Salon', sortOrder: 10, devices: ['158d0002422571', '158d00022aa866'] }
                ]
            }
        }

Then I run MagicMirror. The MMM-xiaomi module is stuck at "Connecting to Xiaomi gateway...", and the console output log is as following:

2019-03-03T21:23:45 <error> TypeError: Cannot read property 'length' of undefined
    at Class.getDevices (/home/pi/MagicMirror/modules/MMM-xiaomi/node_helper.js:70:41)
    at /home/pi/MagicMirror/modules/MMM-xiaomi/node_helper.js:45:20
    at <anonymous> (/: )

I'm sure the gateway token is correct. Could anyone give me some suggestions? Thanks in advance!

mirko3000 commented 5 years ago

Hi, based on the log and the code where it seems to give you the error I would guess no device could be found. Did you try with the miio console tools to identify the connected devices?

xuepgao commented 5 years ago

Yes, I run the command "miio discover" and the gateway was not be found:

......
Device ID: 99235478
Model info: Unknown
Address: 192.168.186.166
Token: ???
Support: Unknown
......

I'm sure the above device is my gateway. I search xiaomi related documents from internet and I almost guess that Xiaomi Air Conditioner Companion (gateway) is not support by miio library.

Thanks for your suggestion.

xuepgao commented 5 years ago

Sorry, devices: '158d0002422571' is a switch, not a temperature/humidity sensor. Thanks!