Coder Social home page Coder Social logo

homebridge-mi-air-purifier's Introduction

homebridge-mi-air-purifier

This is Xiaomi Mi Air Purifier plugin for Homebridge. This plugin will add the air purifier and Air Quality Sensor to your Home app. This version is working with iOS 11 to add the device as air purifier in Home app.

mi-air-purifier

Features

  • Switch on / off.

  • Switch auto / manual mode.

  • Change fan rotation speed.

  • Switch child lock on / off.

  • Switch LED light on / off.

  • Switch buzzer sound on / off.

  • Display temperature.

  • Display humidity.

  • Display air quality.

Installation

  1. Install required packages.

    npm install -g homebridge-mi-air-purifier miio
    

  2. Make sure your Homebridge server is same network with your air purifier, then run following command to discover the token.

    miio discover --sync
    
  3. You may need to wait few minutes until you get the response similar to below:

    Device ID: 49466088
    Model info: Unknown
    Address: 192.168.1.8
    Token: 6f7a65786550386c700a6b526666744d via auto-token
    Support: Unknown
    

  4. Record down the Address and Token values as we need it in our configuration file later.

  5. If you are getting ?????????????? for your token value, please reset your device and connect your Homebridge server directly to the access point advertised by the device.

  6. Then run the command again.

    miio discover --sync
    

  7. Add following accessory to the config.json.

      "accessories": [
        {
          "accessory": "MiAirPurifier",
          "name": "Bed Room Air Purifier",
          "ip": "ADDRESS_OF_THE_AIR_PURIFIER",
          "token": "TOKEN_FROM_STEP_3",
          "showTemperature": true,
          "showHumidity": true,
          "showAirQuality": true,
          "showLED": true,
          "showBuzzer": true
        },
        {
          "accessory": "MiAirPurifier",
          "name": "Living Room Air Purifier",
          "ip": "ADDRESS_OF_THE_AIR_PURIFIER",
          "token": "TOKEN_FROM_STEP_3",
          "showTemperature": true,
          "showHumidity": true,
          "showAirQuality": true,
          "showLED": true,
          "showBuzzer": true
        }
      ]
    

    Notes: Set value for showTemperature, showHumidity, showAirQuality, showLED, showBuzzer to true or false to show or hide these sensors in Home app.

  8. Restart Homebridge, and your Mi air purifier will be added to Home app.

License

See the LICENSE file for license rights and limitations (MIT).

homebridge-mi-air-purifier's People

Contributors

kondratk avatar leoneleone avatar seadog007 avatar seikan avatar yeongrokgim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

homebridge-mi-air-purifier's Issues

New error

I changed nothing but instantly there ist an error and the plug in does not work any more.

node_modules/homebridge-mi-air-purifier/index.js:199:15)
TypeError: Cannot read property 'call' of undefined
^
this.device.call('get_prop', ['favorite_level'])
/usr/local/lib/node_modules/homebridge-mi-air-purifier/index.js:199

Any help please?

ambience light sensor

Air purifier for night mode detection has ambient light sensor. Maybe there is possibility to expose this sensor to homekit ? apple home app supports ambient light sensor (for example Philips hue motion light sensor can bee seen in home app).

Air Purifier - Unresponsive.

Hi There.

Upon the initial install + launch of HomeBridge, says it's running.
But when i go to HomeKit the Air Purifier is unresponsive and not able to be controlled at all.

Running iOS 10.1.1 (JailBroken) not sure if this matters considering the iOS version i'm running.

Not sure what else to do, all the accessories and temperature etc shows up - just not responsive.

Cheers.

Support for zhimi.airpurifier.v7

I bought a xiaomi air purifier pro.
From the process what I get the tokern, I found that the model name is 'zhimi.airpurifier.v7'.
And then this plugin does not work for the 'zhimi.airpurifier.v7'.

index.js:152 crash

/opt/nodejs/lib/node_modules/homebridge-mi-air-purifier/index.js:152
		this.device.call('get_prop', ['mode'])
		            ^

TypeError: Cannot read property 'call' of undefined
    at MiAirPurifier.getTargetAirPurifierState (/opt/nodejs/lib/node_modules/homebridge-mi-air-purifier/index.js:152:15)
    at emitThree (events.js:136:13)
    at Characteristic.TargetAirPurifierState.emit (events.js:217:7)
    at Characteristic.TargetAirPurifierState.Characteristic.getValue (/opt/nodejs/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:162:10)
    at Bridge.<anonymous> (/opt/nodejs/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:756:20)
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._handleGetCharacteristics (/opt/nodejs/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:720:8)
    at emitMany (events.js:147:13)
    at HAPServer.emit (events.js:224:7)
    at HAPServer._handleCharacteristics (/opt/nodejs/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:926:10)

i have an error after installing the mii-air-purifier plugin

[7/11/2017, 6:17:38 AM] ---
[7/11/2017, 6:17:38 AM] ====================
[7/11/2017, 6:17:38 AM] ERROR LOADING PLUGIN homebridge-mi-air-purifier:
[7/11/2017, 6:17:38 AM] SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/usr/local/lib/node_modules/miio/lib/devices/gateway.js:11:19)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/usr/local/lib/node_modules/miio/lib/models.js:7:17)
at Module._compile (module.js:434:26)
[7/11/2017, 6:17:38 AM] ====================

Error device is not a constructor

Hi,
Can’t get the plugin running.
I get Error:miio device is not a constructor at MiAirPurifier.discover.

Can anyone please help?

TypeError: Cannot read property 'power' of undefined

crash when start.

/usr/lib/node_modules/homebridge-mi-air-purifier/index.js:97
                callback(null, this.device.power);
                                          ^

TypeError: Cannot read property 'power' of undefined
    at Object.getOn (/usr/lib/node_modules/homebridge-mi-air-purifier/index.js:97:29)
    at emitThree (events.js:116:13)
    at emit (events.js:194:7)
    at Characteristic.getValue (/usr/lib/node_modules/hap-nodejs/lib/Characteristic.js:129:10)
    at Bridge.<anonymous> (/usr/lib/node_modules/hap-nodejs/lib/Accessory.js:650:20)
    at Array.forEach (native)
    at Bridge.Accessory._handleGetCharacteristics (/usr/lib/node_modules/hap-nodejs/lib/Accessory.js:614:8)
    at emitMany (events.js:127:13)
    at HAPServer.emit (events.js:201:7)
    at HAPServer._handleCharacteristics (/usr/lib/node_modules/hap-nodejs/lib/HAPServer.js:926:10)

Ios11 air purifier support

Hello, I at home you do a little change in the plug-in can be correctly identified as IOS 11 air purifier, correct response work and operation can get equipment, but I have no basis in this field, now is not the right power state feedback, interface button state home.app update is not correct no, do not know if you have time and plan for an upgrade to your this great plugin

The following is my modified version of index.js may have many unreasonable places, laughed————————————————————————

var miio = require('miio');
var Accessory, Service, Characteristic;
var devices = [];

module.exports = function(homebridge) {
Accessory = homebridge.platformAccessory;
Service = homebridge.hap.Service;
Characteristic = homebridge.hap.Characteristic;

homebridge.registerAccessory('homebridge-mi-air-purifier', 'MiAirPurifier', MiAirPurifier);

}

function MiAirPurifier(log, config) {
this.log = log;
this.name = config.name || 'Air Purifier';
this.showAirQuality = config.showAirQuality || false;
this.showTemperature = config.showTemperature || false;
this.showHumidity = config.showTemperature || false;
this.ip = config.ip;
this.token = config.token;
this.device = null;

if(!this.ip)
	throw new Error('Your must provide IP address of the airpurifier.');

if(!this.token)
	throw new Error('Your must provide token of the airpurifier.');


this.services = [];

// Modes supported
this.modes = [
	[0, 'idle'], [60, 'auto'], [80, 'silent'], [100, 'favorite']
];

// Air purifier is not available in Homekit yet, register as Fan
this.AirPurifierService = new Service.AirPurifier(this.name);

this.AirPurifierService
	.getCharacteristic(Characteristic.Active)
	.on('get', this.getPowerState.bind(this))
	.on('set', this.setPowerState.bind(this));

this.AirPurifierService
	.getCharacteristic(Characteristic.RotationSpeed)
	.on('get', this.getRotationSpeed.bind(this))
	.on('set', this.setRotationSpeed.bind(this));

this.services.push(this.AirPurifierService);

this.serviceInfo = new Service.AccessoryInformation();

this.serviceInfo
	.setCharacteristic(Characteristic.Manufacturer, 'Xiaomi')
	.setCharacteristic(Characteristic.Model, 'Air Purifier');

this.services.push(this.serviceInfo);

if(this.showAirQuality){
	this.airQualitySensorService = new Service.AirQualitySensor('Air Quality Sensor');

	this.airQualitySensorService
		.getCharacteristic(Characteristic.AirQuality)
		.on('get', this.getAirQuality.bind(this));

	this.services.push(this.airQualitySensorService);
}

if(this.showTemperature){
	this.temperatureSensorService = new Service.TemperatureSensor('Temperature');

	this.temperatureSensorService
		.getCharacteristic(Characteristic.CurrentTemperature)
		.on('get', this.getCurrentTemperature.bind(this));

	this.services.push(this.temperatureSensorService);
}

if(this.showHumidity){
	this.humiditySensorService = new Service.HumiditySensor('Humidity');

	this.humiditySensorService
		.getCharacteristic(Characteristic.CurrentRelativeHumidity)
		.on('get', this.getCurrentRelativeHumidity.bind(this));

	this.services.push(this.humiditySensorService);
}

this.discover();

}

MiAirPurifier.prototype = {
discover: function(){
var accessory = this;
var log = this.log;

	log.debug('Discovering Mi air purifier devices...');

this.device = miio.createDevice({
address: this.ip,
token: this.token,
model: 'zhimi.airpurifier.m1'
});

	this.device.init()
		.then(function(){
			log.debug('State: ' + accessory.device.state);
			log.debug('speed: ' + accessory.device.speed);
		})
		.catch(function(err){
			log.debug(err);
			throw new Error('Not able to initialize air purifier.');
		});
},

getPowerState: function(callback) {
	if(!this.device){
		callback(null, false);
		return;
	}

	callback(null, this.device.power);
},

setPowerState: function(state, callback) {
	if(!this.device){
		callback(new Error('No air purifier is discovered.'));
		return;
	}

	this.device.setPower(state);
	callback();
},

getCurrentRelativeHumidity: function(callback) {
	if(!this.device){
		callback(null, 0);
		return;
	}

	callback(null, this.device.humidity);
},

getRotationSpeed: function(callback) {
	if(!this.device){
		callback(null, 0);
		return;
	}

	for(var item of this.modes){
		if(this.device.mode == item[1]){
			callback(null, item[0]);
			return;
		}
	}
},

setRotationSpeed: function(speed, callback) {
	if(!this.device){
		callback(new Error('No air purifier is discovered.'));
		return;
	}

	for(var item of this.modes){
		if(speed <= item[0]){
			this.log.debug('Set mode: ' + item[1]);
			this.device.setMode(item[1]);
			break;
		}
	}

	callback();
},

getAirQuality: function(callback) {
	if(!this.device){
		callback(null, Characteristic.AirQuality.UNKNOWN);
		return;
	}

	var levels = [
		[200, Characteristic.AirQuality.POOR],
		[150, Characteristic.AirQuality.INFERIOR],
		[100, Characteristic.AirQuality.FAIR],
		[50, Characteristic.AirQuality.GOOD],
		[0, Characteristic.AirQuality.EXCELLENT],
	];

	var quality = Characteristic.AirQuality.UNKNOWN;

	for(var item of levels){
		if(this.device.aqi > item[0]){
			quality = item[1];
			break;
		}
	}

	callback(null, quality);
},

getCurrentTemperature: function(callback) {
	if(!this.device){
		callback(null, 0);
		return;
	}

	callback(null, this.device.temperature);
},

identify: function(callback) {
	callback();
},

getServices: function() {
	return this.services;
}

};

this.device error

Hey there! I am getting this error when starting up homebridge, any ideas?

[2018-1-25 20:58:10] [Mi Air Crusher! - Livingroom] Initializing MiAirPurifier accessory...
/usr/local/lib/node_modules/homebridge-mi-air-purifier/index.js:110
this.device = new miio.Device({
^

TypeError: miio.Device is not a constructor
at MiAirPurifier.discover (/usr/local/lib/node_modules/homebridge-mi-air-purifier/index.js:110:17)
at MiAirPurifier (/usr/local/lib/node_modules/homebridge-mi-air-purifier/index.js:105:7)
at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:275:29)
at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:86:38)
at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)

Cool plugin, nice job!

Stable, fast response plug-in, thank you for your work, miio can increase Mi smart plug-ins based on the fan, I can use miio to complete the control of it, but I do not have to complete their ability to write plug-ins, thanks again

starting with another homebridge plugin

Im already have homebridge with running homebridge-broadlink-rm
After adding Mi-Purifier in config.js its starting, but not find any accessories

Loaded plugin: homebridge-broadlink-rm
[2018-3-13 01:35:36] Registering platform 'homebridge-broadlink-rm.BroadlinkRM'
[2018-3-13 01:35:36] ---
[2018-3-13 01:35:36] Loaded plugin: homebridge-mi-air-purifier
[2018-3-13 01:35:36] Registering accessory 'homebridge-mi-air-purifier.MiAirPurifier'
[2018-3-13 01:35:36] ---
[2018-3-13 01:35:36] Loaded config.json with 0 accessories and 1 platforms.
[2018-3-13 01:35:36] ---
[2018-3-13 01:35:36] Loading 1 platforms...
[2018-3-13 01:35:36] [Broadlink RM] Initializing BroadlinkRM platform...
[2018-3-13 01:35:36] [Broadlink RM] Initializing platform accessory 'Learn'...
.....
[2018-3-13 01:35:36] [Broadlink RM] Initializing platform accessory 'TV box'...

[2018-3-13 01:35:36] Loading 0 accessories...

Config.json

{
"bridge": {
"name": "Homebridge",
"username": "CC:21:3E:E4:DE:33",
"port": 49677,
"pin": "031-45-154"
},
"description": "Configuration file for (e)xtended Domoticz platform.",
"accessories": [
{

			"accessory": "MiAirPurifier",
			"type": "air-purifier",
			"name": "Air Purifier",
			 "ip": "192.168.0.220 ",
			"token": "77f7f51ee81406bba6349796699f0aa3",
			 "showTemperature": true,
			 "showHumidity": true,
			 "showAirQuality": true
			}
			  ],

"platforms": [{
		"platform": "BroadlinkRM",
		"name": "Broadlink RM",
		"hideScanFrequencyButton": false,
		"hideLearnButton": false,
		"accessories": [{
				"name": "TV On/Off",
				"type": "switch",
				"host":"192.168.0.25",
				"data": {
						"on":"....

Cannot turn on-off from Home app

Pressing the off button on the Home app (or the Eve app) causes the device to shut down but the button says Turning Off and then times out and always shows ON.

Add miio as dependency in package.json

First, thanks for using miio to build something awesome! I recently released version 0.15.x of miio which introduces several incompatible changes. The API in miio is slowly becoming more stable but until we reach 1.0.0 there are going to be breaking changes in some releases.

It would be great if you could update your Homebridge-plugin to use miio as a local dependency instead of a global dependency. That way installing your plugin will automatically install the version of miio needed. The easiest way to do this is to use npm install in your project and to set the version to 0.14.1:

npm install --save [email protected]

That way your users and you will get version 0.14.1 until you are ready to update your plugin to the new API available in 0.15.x.

Unable to get the Homebridge to run after updating the config.json

Hi,

I have the following lines in my config.json and am getting an error (mentioned below) whenever I am trying to get the HomeBridge app run.

config.json

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 58750,
        "pin": "015-23-741"
    },
    
    "description": "Sajat's Homebridge",
    
    "accessories": [
    	{
    		"accessory": "MiAirPurifier",
    		"name": "Air Purifier",
    		"ip": "192.168.1.68",
    		"token": "ca616a1b9287046350edebbbab6c62b2",
    		"showTemperature": true,
    		"showHumidity": true,
    		"showAirQuality": true
    	}
    ]
}

Error

events.js:137
      throw er; // Unhandled 'error' event
      ^
Error: listen EADDRINUSE :::58750
    at Object._errnoException (util.js:1003:13)
    at _exceptionWithHostPort (util.js:1024:20)
    at Server.setupListenHandle [as _listen2] (net.js:1366:14)
    at listenInCluster (net.js:1407:12)
    at Server.listen (net.js:1495:7)
    at EventedHTTPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/eventedhttp.js:60:19)
    at HAPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:158:20)
    at Bridge.Accessory.publish (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:607:16)
    at Server._publish (/usr/local/lib/node_modules/homebridge/lib/server.js:126:16)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:96:10)

My Homebridge installation is brand new and this is the only accessory I have been trying to install.

Thank you.

Regards,
Sajat

will this work if firewall is set to only allow purifier to communicate on local network?

For security reasons I like to wall off my internet-of-things devices from the internet and control them over the local network. Do you know if your software can be used with a xiaomi purifier that only has LAN but not WAN access - or maybe does the xiaomi purifier need to "phone home" to servers in China in order to function?

Thanks for any information.

On a different note - it appears there's a similar-looking homebridge plugin for the xiaomi purifiers. I'm not sure how it differs from this one.

There is only one air purifier

Thank you very much for your program.
Now I have a problem.
My family has three air purifiers, but only one can be found.
Hope to continue to improve the program.

Failed to discover Mi Air Purifier at 192.168.1.10

I'm getting this in the log. This is definitely the correct ip. I have a Mi 2S latest firmware. I know the token is correct. I can ping the ip just fine.

Failed to discover Mi Air Purifier at 192.168.1.10
Will retry after 30 seconds

{
"accessory": "MiAirPurifier",
"name": "Bed Room Air Purifier",
"ip": "192.168.1.10",
"token": "xxxxx",
"showTemperature": true,
"showHumidity": true,
"showAirQuality": true,
"showLED": true,
"showBuzzer": true
}

Add Filter Life Characteristics??

@seikan

Thank you for making this plugin. I just have one small request:

Is there any way you can add the two Characteristics listed below to the AirPurifier Service?
`/**

  • Characteristic "Filter Change Indication"
    */

Characteristic.FilterChangeIndication = function() {
Characteristic.call(this, 'Filter Change Indication', '000000AC-0000-1000-8000-0026BB765291');
this.setProps({
format: Characteristic.Formats.UINT8,
maxValue: 1,
minValue: 0,
validValues: [0,1],
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.value = this.getDefaultValue();
};

inherits(Characteristic.FilterChangeIndication, Characteristic);

Characteristic.FilterChangeIndication.UUID = '000000AC-0000-1000-8000-0026BB765291';

// The value property of FilterChangeIndication must be one of the following:
Characteristic.FilterChangeIndication.FILTER_OK = 0;
Characteristic.FilterChangeIndication.CHANGE_FILTER = 1;

/**

  • Characteristic "Filter Life Level"
    */

Characteristic.FilterLifeLevel = function() {
Characteristic.call(this, 'Filter Life Level', '000000AB-0000-1000-8000-0026BB765291');
this.setProps({
format: Characteristic.Formats.FLOAT,
maxValue: 100,
minValue: 0,
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.value = this.getDefaultValue();
};

inherits(Characteristic.FilterLifeLevel, Characteristic);

Characteristic.FilterLifeLevel.UUID = '000000AB-0000-1000-8000-0026BB765291';
`

I'm not sure the Characteristics will be visible in the Home app, but I believe adding them would give the user a HomeKit Notification when the Filter needs to be changed. That would be a great function to have 🙂

Is this possible?

Anyway to publish temperature and humidity to mqtt broker?

Hello,

Been using your plugin and really like it as it's super useful. However, I would like to know if there is anyway to publish the temperature and humidity value to mqtt broker so that the data can be useful in other resources as well?

Thank you and looking forward to hearing from you.

Installation error help~

^Cpi@raspberrypi:~ $ npm install -g homebridge-mi-air-purifier miio
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
/usr/lib
├── [email protected]
└─┬ [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
└─┬ [email protected]
└── [email protected]

npm ERR! Linux 4.9.35-v7+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "homebridge-mi-air-purifier" "miio"
npm ERR! node v7.10.0
npm ERR! npm v4.2.0
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/.npm/_logs/2017-07-11T15_34_58_430Z-debug.log
pi@raspberrypi:~ $

HomeKit and Homebridge support new Air Purifier service in iOS11

Could you add a new branch that make use of the new air purifier type for iOS11 HomeKit?

Or can you think of a better way to deal with the problem (for users running iOS10 which doesn't support air purifier and users for iOS11)?

I'm thinking that maybe we could add config.isIOS11 in the config file to determine that. Or does Homebridge provides an API to check the iOS version?

目前的版本是支持多设备的

目前有三台小米空净,小米2、小米2S、小米Pro.按照documents来安装homebridge-mi-air-purifier,配置文件这样写:
"accessories": [ { "accessory": "MiAirPurifier", "name": "Air Purifier", "ip": "10.0.1.46", "token": "4cd8ba2d8368ca27e2b9d735d7379cff", "showTemperature": true, "showHumidity": true, "showAirQuality": true }, { "accessory": "MiAirPurifier", "name": "Air Purifier3", "ip": "10.0.1.17", "token": "9ca2e20e9c855a184bc48ad1a6b0e414", "showTemperature": true, "showHumidity": true, "showAirQuality": true }, { "accessory": "MiAirPurifier", "name": "Air Purifier2", "ip": "10.0.1.29", "token": "ed658a1d27328f91868d509696166897", "showTemperature": true, "showHumidity": true, "showAirQuality": true }
测试成功.

Crash with the 1.3.0 version

Hello,

I have new issue with the latest version, so i have this trace 5 second after homebridge start :

(node:2789) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'call' of null
    at MiAirPurifier.getRotationSpeed (/usr/lib/node_modules/homebridge-mi-air-purifier/index.js:291:27)
    at emitThree (events.js:136:13)
    at Characteristic.RotationSpeed.emit (events.js:217:7)
    at Characteristic.RotationSpeed.Characteristic.getValue (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:163:10)
    at Bridge.<anonymous> (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:760:20)
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._handleGetCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:724:8)
    at emitMany (events.js:147:13)
    at HAPServer.emit (events.js:224:7)
    at HAPServer._handleCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:926:10)
(node:2789) 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:2789) [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.
(node:2789) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'call' of null
    at MiAirPurifier.getLockPhysicalControls (/usr/lib/node_modules/homebridge-mi-air-purifier/index.js:272:27)
    at emitThree (events.js:136:13)
    at Characteristic.LockPhysicalControls.emit (events.js:217:7)
    at Characteristic.LockPhysicalControls.Characteristic.getValue (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:163:10)
    at Bridge.<anonymous> (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:760:20)
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._handleGetCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:724:8)
    at emitMany (events.js:147:13)
    at HAPServer.emit (events.js:224:7)
    at HAPServer._handleCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:926:10)
(node:2789) 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: 2)

Can you help me ?

[email protected]
[email protected]
[email protected]

My config file :

{
    "bridge": {
        "name": "Homebridge",
        "username": "XXXXX",
        "port": XXXX,
        "pin": "XXXX"
    },
    "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.",
    "accessories": [
        {
            "accessory": "MiAirPurifier",
            "name": "Air Purifier",
            "ip": "XXXX",
            "token": "XXXX",
            "showTemperature": true,
            "showHumidity": true,
            "showAirQuality": true
        }
    ],
    "platforms": [
        {
            "platform": "DysonPlatform",
            "name": "DysonPlatform",
            "accessories": [
                {
                    "ip": "XXX",
                    "displayName": "Dyson",
                    "serialNumber": "XXXX",
                    "password": "XXX"
                }
            ]
        }
    ]
}

Cannot run. Homebridge service terminated

Following the prompt installation, the following error occurs after configuring the config

——————————————————————————————————————————

/usr/local/lib/node_modules/homebridge-mi-air-purifier/index.js:114
if(this.device.mode == item[1]){
^

TypeError: Cannot read property 'mode' of undefined
at MiAirPurifier.getRotationSpeed (/usr/local/lib/node_modules/homebridge-mi-air-purifier/index.js:114:18)
at emitThree (events.js:116:13)
at Characteristic.RotationSpeed.emit (events.js:197:7)
at Characteristic.RotationSpeed.Characteristic.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:129:10)
at Bridge. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:650:20)
at Array.forEach (native)
at Bridge.Accessory._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:614:8)
at emitMany (events.js:127:13)
at HAPServer.emit (events.js:204:7)
at HAPServer._handleCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:926:10)
logout

TypeError: miio.createDevice is not a function

Hi I'm having this error when running, please assist:

[2018-1-25 13:54:59] [Air Purifier] Initializing XiaoMiAirPurifier accessory...
/usr/lib/node_modules/homebridge-xiaomi-air-purifier/index.js:106
var device = miio.createDevice({
^

TypeError: miio.createDevice is not a function
at XiaoMiAirPurifier.discover (/usr/lib/node_modules/homebridge-xiaomi-air-purifier/index.js:106:27)
at new XiaoMiAirPurifier (/usr/lib/node_modules/homebridge-xiaomi-air-purifier/index.js:99:10)
at Server._loadAccessories (/usr/lib/node_modules/homebridge/lib/server.js:275:29)
at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:86:38)
at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:40:10)
at Object. (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)

Thank you

Cant find my Mi Air purifier 2

HI, i follow the instructions, installed the plugin, but while running home bridge, i type the command:

miio --discover --sync

and the only thing that shows up after a few minutes its my broadlink RM Pro, nothing else ...

Homebridge Server is running on the same network as the Air purifier, what am i doing wrong?

thanks

Unexpected token function, fail to loading plugin.

my node version is v6.14.3

[6/28/2018, 2:49:56 AM] ====================
[6/28/2018, 2:49:56 AM] ERROR LOADING PLUGIN homebridge-mi-air-purifier:
[6/28/2018, 2:49:56 AM] /usr/lib/node_modules/homebridge-mi-air-purifier/index.js:296
    getLockPhysicalControls: async function(callback) {
                                   ^^^^^^^^

SyntaxError: Unexpected token function
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Plugin.load (/usr/lib/node_modules/homebridge/lib/plugin.js:72:22)
[6/28/2018, 2:49:56 AM] ====================

typo in example config

not a dot, there must be a comma

"accessories": [
{
"accessory": "MiAirPurifier",
"name": "Air Purifier",
"ip": "ADDRESS_OF_THE_AIR_PURIFIER",
"token": "TOKEN_FROM_STEP_3",
"showTemperature": true,
"showHumidity": true,
"showAirQuality": true
}
]

Works but status will get stuck on turning on

I am using this with my Mi Air Purifier 2. It works perfectly except a small bug where the status will get stuck on turning on or turning off. Restarting the Home app will make it return to normal. Happening on iOS 11, any ideas on this? Thanks.

How to install on a Raspberry with HASSIO

Hi Master,

I'm really a newbie for this, and I run HB with HASSIO on Raspberry, it seems there's no nodejs and npm(actually I even don't know what they are), how can I install your plugins?

Thanks.

Version 1.2.2 Night Mode/ Automatic Mode

Hi,

how can I activate the night mode with version 1.2.2? If the mode is set to manual, 5-7qm is the minimum value to set. The automatic mode does not always work, even if it is set automatically via HomeKit it runs in manual mode.

Mossbian系统中通过web homebridge添加插件报错无法使用

搞不定的问题,特此向作者请教。首先感谢作者提供如此给力插件。我单独架设的homebridge,通过npm install -g homebridge-mi-air-purifier miio命令安装以后,配置好config可以正常加载插件。
但是我安装了Mossbina以后,通过HA-HB,然后在web界面加载以后就发现问题了,首先插件安装是搜索安装的。如图我安装了这个插件
default
同样配置以后就报错,错误如下:
default
字面意思是找不到miio组件,但是这种系统的架设和单独架设homebridge不太一样,是否是我没有正确安装miio组件,请问作者你有没有尝试过这个系统,如何在这个系统中安装你这个插件,多谢。

i study homekit on raspbian,but it is wrong like this

[1/25/2018, 1:10:48 PM] [Air Purifier] Initializing MiAirPurifier accessory...
/usr/lib/node_modules/homebridge-mi-air-purifier/index.js:110
this.device = new miio.Device({
^

TypeError: miio.Device is not a constructor
at Object.discover (/usr/lib/node_modules/homebridge-mi-air-purifier/index.js:110:17)
at Object.MiAirPurifier (/usr/lib/node_modules/homebridge-mi-air-purifier/index.js:105:7)
at Server._loadAccessories (/usr/lib/node_modules/homebridge/lib/server.js:275:29)
at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:86:38)
at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:40:10)
at Object. (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)

The 1.4.0 version cannot register in homebridge

The plugin works fine in 1.2.2, but cannot work in 1.4.0
Hope the following error message may help you fix this issue. Thank you.

[7/30/2018, 10:05:40 PM] ---
[7/30/2018, 10:05:40 PM] ====================
[7/30/2018, 10:05:40 PM] ERROR LOADING PLUGIN homebridge-mi-air-purifier:
[7/30/2018, 10:05:40 PM] /usr/lib/node_modules/homebridge-mi-air-purifier/index.js:296
    getLockPhysicalControls: async function(callback) {
                                   ^^^^^^^^

SyntaxError: Unexpected token function
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Plugin.load (/usr/lib/node_modules/homebridge/lib/plugin.js:72:22)
[7/30/2018, 10:05:40 PM] ====================

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.