From 03e205b7f9bd5c4f6f0ce4ac219b3465939033d0 Mon Sep 17 00:00:00 2001 From: Algram Date: Sun, 27 Jan 2019 16:44:06 +0100 Subject: [PATCH 1/2] Added model check to avoid calling miio.info --- lib/network.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/network.js b/lib/network.js index 78765da..1f0cc4f 100644 --- a/lib/network.js +++ b/lib/network.js @@ -305,6 +305,14 @@ class DeviceInfo { promise = Promise.resolve(); } + // Check if a model was already provided + if (this.model) { + this.enriched = true; + this.tokenChanged = false; + + this.enrichPromise = null; + } + return this.enrichPromise = promise .then(() => this.call('miIO.info')) .then(data => { From 158551964dde4ec283d8d4d3d8b36d2143291183 Mon Sep 17 00:00:00 2001 From: Algram Date: Mon, 4 Mar 2019 21:08:55 +0100 Subject: [PATCH 2/2] Add promise resolve for faster responses --- lib/network.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/network.js b/lib/network.js index 1f0cc4f..56f7aed 100644 --- a/lib/network.js +++ b/lib/network.js @@ -310,7 +310,7 @@ class DeviceInfo { this.enriched = true; this.tokenChanged = false; - this.enrichPromise = null; + return Promise.resolve() } return this.enrichPromise = promise