maxinminax / node-mihome

Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more
MIT License
121 stars 35 forks source link

Luminance Sensor Values #40

Open CarlosMaxiwatt opened 3 years ago

CarlosMaxiwatt commented 3 years ago

I have a Luminance Light Sensor Mijia Zigbee 3.0 and a Xiaomi Motion Sensor. connected to Xiaomi Multi-mode Smart Gateway 2020 Wifi Zigbee Hub Brige.

When I run "mihome.miCloudProtocol.getDevices" , returned me both sensors (for example "AAAAAAAA" and "BBBBBBB" id, mac, etc). But now I want to get the values of both sensors. I think I must to use something similar to "mihome.miCloudProtocol.miioCall( "AAAAAAAA" , method )". But I don't know which Method is to get the Luminance value, or the last motion value. I don't know where I can find the methods of each device.

Tahnk you.

Pittini commented 3 years ago

Maybe here are some helpful links to determine the methods: https://gist.github.com/Pittini/1a333de9d0d5397c0a01e4fa127995c1

CarlosMaxiwatt commented 3 years ago

Hello Pittini. Thank you very Much. I tried according to your Document. But I can't still understand.

According to node-mihome documentation: await mihome.miCloudProtocol.miioCall(deviceId, method, params, options); // call miio method with params via cloud protocol

So I tried something like this: mihome.miCloudProtocol.miioCall("255742660", "miot-spec-v2" )

And returned null.

What I'm doing Wrong? Which one is correctly?: mihome.miCloudProtocol.miioCall("255742660", "miot-spec-v2" ) or mihome.miCloudProtocol.miioCall("255742660", "http://miot-spec.org/miot-spec-v2/instances?status=all" )

No one retunr values.

My Code:

mihome.miCloudProtocol.login(username, password).then(response => { //Works fine }); mihome.miCloudProtocol.getDevices(null, options).then(devices => { //Works fine, one of the ID devices is 255742660 console.log(response); }); mihome.miCloudProtocol.miioCall("255742660", "http://miot-spec.org/miot-spec-v2/instances?status=all" ).then(devices => { console.log(response); //Always return NULL });

Pittini commented 3 years ago

The Links are just for finding out which properties/methods a device have. Your device has to be here: https://github.com/maxinminax/node-mihome/tree/master/lib/devices . If not, you cant control or get values exept the base info like ip model, etc. I don't know your skill level, but maybe my old testcode can help you to understand. Thats the smallest version, the actual one is much bigger for use with the iobroker smarthome system.

CarlosMaxiwatt commented 3 years ago

Hello @Pittini . Thank you a lots for your time. I didn't found neither the Zigbee Gateway, neither Light Sensor Mijia Zigbee.

Furthermore, your old test at this moment isn't avaliable.

But according to your info, this soud be the correct way? For example, if I have a model 'lumi.sensor_motion.aq2' with ID '255742660':

mihome.miCloudProtocol.miioCall("255742660", "getBattery() " ).then(devices => { console.log(response);