miio icon indicating copy to clipboard operation
miio copied to clipboard

Getting value from Motion Sensor

Open codenchip opened this issue 4 years ago • 1 comments

I am trying to get state and motion values from the Mi Aqara 2 Motion Sensor but have no luck doing so. I only got null for motion, illuminance and -1 for battery level.

Can someone pls help or point me in the right direction?

This is my code so far. I have saved the token in token.json file.

const miio = require('miio'); var token = '*********************************' //gateway var address = '***.***.***.***' // gateway // var address='***.***.***.***' lightstrip var sensorId = '************'; miio.device({ address: address }) .then(device => { for (d of device.children()) { if(d.internalId==sensorId){ console.log('Connected to', d.metadata); // d.on('motionChanged').then(data => console.log(data)).catch(console.error); // d.illuminance().then(data => console.log(data)).catch(console.error); // d.state().then(data => console.log(data)).catch(console.error); // console.log(d.illuminance()); // console.log(d.motion()); } } })

codenchip avatar Aug 12 '19 14:08 codenchip

The Aqara motion sensor is a Zigbee device. How did you get an IP address for address? Zigbee is not IP-based...

tricoos avatar Jun 27 '20 17:06 tricoos