Timeout issue
ae3e opened this issue · 2 comments
ae3e commented
Hi,
I'm trying to get data from my miflora device with your package but I'm getting stuck with a timeout error.
Here is my simple sample code :
const miflora = require('miflora');
(async function () {
const opts = {
duration: 60000,
ignoreUnknown: true,
addresses: ['c4:7c:8d:67:be:d0']
};
const devices = await miflora.discover(opts);
console.log('devices discovered: ', devices.length);
if (devices.length>0){
const device = devices[0];
let data = await device.query();
console.log(data);
}
})();
and here is the trace log in debug mode.
miflora waiting for adapter state change +0ms
miflora adapter changed to to 'poweredOn' +30ms
miflora starting discovery with 60000ms duration +3ms
miflora (discovery will be stopped when [ 'c4:7c:8d:67:be:d0' ] is found) +0ms
miflora discovery started +11ms
miflora discovered MiFloraMonitor @ c4:7c:8d:67:be:d0 +535ms
miflora found all requested devices, stopping discovery +0ms
miflora discovery finished +4ms
devices discovered: 1
miflora:device:c4:7c:8d:67:be:d0 querying multiple information +0ms
miflora:device:c4:7c:8d:67:be:d0 querying firmware information +1ms
miflora:device:c4:7c:8d:67:be:d0 initiating connection +1ms
miflora:device:c4:7c:8d:67:be:d0 connected to device +3s
miflora:device:c4:7c:8d:67:be:d0 connected, resolving chars +1ms
miflora:device:c4:7c:8d:67:be:d0 resolving characteristic +2ms
(node:16566) UnhandledPromiseRejectionWarning: Error: timeout
at Timeout.setTimeout [as _onTimeout] (/home/pi/Documents/shared/flora/node_modules/miflora/lib/miflora-device.js:11:20)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
(node:16566) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16566) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
miflora:device:c4:7c:8d:67:be:d0 disconnected from device +10s
Any idea?
Thanks for your help
ChrisScheffler commented
I get timeouts when devices are far away from the device running node. Could you repeat the run with the devices being closer together?
ae3e commented
Thanks !
Finally, the issue was caused by an another script running at the same time to read Xiaomi Mijia temperature and humidity sensors... When I shut it down, I can read my miflora sensor.
Sorry for the inconvenience...