Closed 0x2206 closed 3 years ago
For unsupported devices, you can made a new class same as the device class which you can find in /lib/devices
. So if you have other models and can test, you can made the PR, I will merge it asap
Yes, adding lacking device implementation is exactly what I did with my fork. As for now locally.
What I mean is, imagine there is another device like vacuum cleaner released to the market next week. I am pretty sure most props and actions would be the same as for current vacuums. But that new vacuum won't work until someone adds new class to /lib/devices/
. What I propose is to have a fallback in such situations. Consumers of this lib would use fallback implementation until dedicated one is added. What do you think?
Anyone can implement the Device class to create new model
const Device = require('node-miio/device-miio');
class GenericDevice extends Device {
// example class can find in folder /lib/devices
}
const device = new GenericDevice(options);
// use device as normal
Currently, when you try to use unsupported model, so file with precisely the same name is not found in
/lib/devices/
, it raises error. How about being less restrictive and fall back to (more generic) device group then?As an example, I want to communicate with (currently unsupported) Mi Air Purifier Pro (
model: zhimi.airpurifier.v6
), which has the same props to get and set as (currently supported)model: zhimi.airpurifier.v7
. I propose to have more generic, virtual model likezhimi.airpurifier
which is used in such situations.In fact, that more generic model will be based on simpler air purifier, as:
but that is implementation detail.