Comments (4)
Thanks for the report. device.init()
is used to setup and load initial properties for most devices. It should load properties from the vacuum as well, at least the first time it is called. Calling init()
is considered advanced usage together with miio.createDevice()
. In most cases you should use miio.device()
if you want to connect via IP.
Can you share how you are creating the initial device handle?
from miio.
//create device
let device = miio.createDevice({
address: this.config.ip,
token: this.config.token,
model: 'rockrobo.vacuum.v1'
});
if (this.config.sid == undefined) {
this.config.sid = this.config.ip; //change sid
}
device.init()
.then(() => {
this.mijia.log.debug('init vacuum done->%s', this.config.ip);
this.mijia.log.debug('Battery->%s,State->%s,Fan->%s', device.battery, device.state, device.fanPower);
if (device.state != undefined) {
this.setVacuum(this.config, device);
this.devices[this.config.sid] = device;
} else {
this.mijia.log.warn('vacuum state undefined, discard to setVacuum');
device.destroy();
}
})
.catch((err) => {
this.mijia.log.error(err);
throw new Error('unable to initialize robot vacuum->%s', this.config.ip);
});
if i config a wrong ip address,like 1.1.1.1
, the then
section will always to be call.
so i have to check the state,if device.state!=undefined ,i will register a homekit accessory.otherwise discard it.
i think ,if it can't init success,will goto catch
section(promise.reject).
from miio.
Looks like any errors during init are being suppressed right now. I'll do a fix for the next release.
In your use case it looks like you probably want to use miio.device()
instead of miio.createDevice()
which will connect, resolve the model and initialize the device properly. That method will fail if it can not connect to the device.
from miio.
ok,i see.
thank you ~
from miio.
Related Issues (20)
- Not enough non-option arguments: got 0, need at least 1 error Command failed with exit code 1.
- Xiaomi Air Monitor cgllc.airm.cgdn1
- yeelight strip plus is supported?
- Canβt find Hub / Temperature-Sensors
- yeelink.light.color5 HOT 1
- Mi Smart LED Bulb (B22) - Support
- yeelink.light.mono6 HOT 1
- [add device request] yeelink.light.ceilb
- [add device request] yeelink.light.colorb
- -Bash: miio: command not found HOT 1
- doesn't work on Firmware version: 3.2.10
- Cannot connect to light after configuring wireless network HOT 1
- yeelink.light.bslamp2 HOT 2
- Create device with lib version >= 0.15.0
- Which devices can get tokens by "miio discover" or "mirobo discover --handshake 1"?
- Does this packge still getting maintained?
- Roborock S6 - 3.5.8._2902 - unsupported device
- colorTemperature2rgbUsingTH is not defined
- Device support [Vacum mop 2 ultra]
- Error connecting to device: Error: Call to device timed out
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miio.