fison67 / mi_connector

Connector for Xiaomi Devices with Smartthings, Hubitat
MIT License
213 stars 595 forks source link

lumi.ctrl_ln2.aq1 not recognised by mi connect #43

Closed droliverlewis closed 5 years ago

droliverlewis commented 5 years ago

Hi, I'm having issues connecting a lumi.ctrl_ln2.aq1 to mi connect. Here is what appears to happen:

In the Mi Home app (Hub info page) the device is identified as :{"model":"lumi.ctrl_ln2.aq1","did":"lumi.158d00023b265c","name":"Hall Light"}

When this is pulled into the mi connector application, on the page Add device [ST] it comes up as follows:

Then I attempt to register the device, mi connect throws an error. This doesn't happen for any other devices (I also have a lumi.ctrl_neutral2 which works fine).

Any thoughts? Thank you

PS: Fantastic tool. NB: The gateway tokens now appear in the "Hub info" page of the Mi Home app once the wireless communication protocol, so no need to try to strip them out of the DB any more.

droliverlewis commented 5 years ago

Sorry, forgot to give you the log entry when I try to register the device with ST:

Get Device State TypeError: deviceMap[id].target.state is not a function Error at Object.module.exports.getDeviceState (/usr/src/app/miio/miio.js:1487:55) at /usr/src/app/routes/registerST.js:20:10 at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5) at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13) at isAuthenticated (/usr/src/app/routes/dashboard.js:21:12) at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5) at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5) at /usr/src/app/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12) at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10) at Function.handle (/usr/src/app/node_modules/express/lib/router/index.js:174:3) at router (/usr/src/app/node_modules/express/lib/router/index.js:47:12) at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)

It just looks like mi_connector hasn't been able to ID the device type successfully and has just allocated it as a generic/unknown device.

droliverlewis commented 5 years ago

Been playing in the docker image (couldn't find sources), to see if I could find the problem and it looks like two changes are required to get lumi.ctrl_ln2.aq1 devices to work:

1. /usr/src/app/node_modules/miio/lib/devices/gateway/subdevices.js

following entry needs to be added to the module.exports: 64: require('./ctrl_ln2'),

2. /usr/src/app/miio/miio.js - line 384

Change if(child.miioModel == "lumi.ctrl_neutral2" || child.miioModel == "lumi.ctrl_neutral2") to if(child.miioModel == "lumi.ctrl_neutral2" || child.miioModel == "lumi.ctrl_ln2")

Maybe fison76 could verify this and add it properly.

fison67 commented 5 years ago

Maybe this 64? is a new model. I will update a source.

Thanks much.