Skip to content

Commit

Permalink
Release 2.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jghaanstra committed Sep 5, 2018
1 parent 181cef0 commit 3ada641
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 40 deletions.
1 change: 1 addition & 0 deletions APPSTORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Xiaomi has recently released an update for its v1 vacuum that enabled it for the
### 2018-09-05 - v2.8.2
* FIX: fixed bug with return to dock action card for Vacuum Cleaner
* FIX: fixed where the Vacuum Cleaner always shows as charging even thought the battery is full
* IMPROVEMENT: better error catching in polling mechanism for miio devices
* UPDATE: removed support for Philips Eyecare since there is a bug in the miio library for this device (see https://github.com/aholstenson/miio/issues/145)

### 2018-08-22 - v2.8.1
Expand Down
9 changes: 8 additions & 1 deletion drivers/air-monitor/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class MiAirMonitorDevice extends Homey.Device {
address: this.getSetting('address'),
token: this.getSetting('token')
}).then(miiodevice => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.miio = miiodevice;

var interval = this.getSetting('polling') || 60;
Expand Down Expand Up @@ -61,8 +64,12 @@ class MiAirMonitorDevice extends Homey.Device {
this.setAvailable();
}
} catch (error) {
this.setUnavailable(Homey.__('unreachable'));
this.log(error);
clearInterval(this.pollingInterval);
this.setUnavailable(Homey.__('unreachable'));
setTimeout(() => {
this.createDevice();
}, 1000 * interval);
}
}
getData();
Expand Down
9 changes: 8 additions & 1 deletion drivers/gateway/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class GatewayDevice extends Homey.Device {
address: this.getSetting('address'),
token: this.getSetting('token')
}).then(miiodevice => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.miio = miiodevice;
this.miio.light = miiodevice.child('light');

Expand Down Expand Up @@ -116,8 +119,12 @@ class GatewayDevice extends Homey.Device {
this.setAvailable();
}
} catch (error) {
this.setUnavailable(Homey.__('unreachable'));
this.log(error);
clearInterval(this.pollingInterval);
this.setUnavailable(Homey.__('unreachable'));
setTimeout(() => {
this.createDevice();
}, 1000 * interval);
}
}
getData();
Expand Down
9 changes: 8 additions & 1 deletion drivers/mi-airpurifier/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class MiAirPurifierDevice extends Homey.Device {
address: this.getSetting('address'),
token: this.getSetting('token')
}).then(miiodevice => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.miio = miiodevice;

var interval = this.getSetting('polling') || 60;
Expand Down Expand Up @@ -69,8 +72,12 @@ class MiAirPurifierDevice extends Homey.Device {
this.setAvailable();
}
} catch (error) {
this.setUnavailable(Homey.__('unreachable'));
this.log(error);
clearInterval(this.pollingInterval);
this.setUnavailable(Homey.__('unreachable'));
setTimeout(() => {
this.createDevice();
}, 1000 * interval);
}
}
getData();
Expand Down
9 changes: 8 additions & 1 deletion drivers/mi-humidifier/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class MiHumidifierDevice extends Homey.Device {
address: this.getSetting('address'),
token: this.getSetting('token')
}).then(miiodevice => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.miio = miiodevice;

var interval = this.getSetting('polling') || 60;
Expand Down Expand Up @@ -65,8 +68,12 @@ class MiHumidifierDevice extends Homey.Device {
this.setAvailable();
}
} catch (error) {
this.setUnavailable(Homey.__('unreachable'));
this.log(error);
clearInterval(this.pollingInterval);
this.setUnavailable(Homey.__('unreachable'));
setTimeout(() => {
this.createDevice();
}, 1000 * interval);
}
}
getData();
Expand Down
9 changes: 8 additions & 1 deletion drivers/mi-power-plug/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class PowerPlugDevice extends Homey.Device {
address: this.getSetting('address'),
token: this.getSetting('token')
}).then(miiodevice => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.miio = miiodevice;

var interval = this.getSetting('polling') || 30;
Expand All @@ -52,8 +55,12 @@ class PowerPlugDevice extends Homey.Device {
this.setAvailable();
}
} catch (error) {
this.setUnavailable(Homey.__('unreachable'));
this.log(error);
clearInterval(this.pollingInterval);
this.setUnavailable(Homey.__('unreachable'));
setTimeout(() => {
this.createDevice();
}, 1000 * interval);
}
}
getData();
Expand Down
9 changes: 8 additions & 1 deletion drivers/mi-power-strip/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class PowerStripDevice extends Homey.Device {
address: this.getSetting('address'),
token: this.getSetting('token')
}).then(miiodevice => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.miio = miiodevice;

var interval = this.getSetting('polling') || 30;
Expand Down Expand Up @@ -61,8 +64,12 @@ class PowerStripDevice extends Homey.Device {
this.setAvailable();
}
} catch (error) {
this.setUnavailable(Homey.__('unreachable'));
this.log(error);
clearInterval(this.pollingInterval);
this.setUnavailable(Homey.__('unreachable'));
setTimeout(() => {
this.createDevice();
}, 1000 * interval);
}
}
getData();
Expand Down
82 changes: 49 additions & 33 deletions drivers/mi-robot/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class MiRobotDevice extends Homey.Device {
address: this.getSetting('address'),
token: this.getSetting('token')
}).then(miiodevice => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.miio = miiodevice;

var interval = this.getSetting('polling') || 60;
Expand All @@ -101,42 +104,55 @@ class MiRobotDevice extends Homey.Device {
clearInterval(this.pollingInterval);

this.pollingInterval = setInterval(() => {
var battery = this.miio.getState('batteryLevel');
var fanspeed = this.miio.getState('fanSpeed');
const getData = async () => {
try {
var battery = this.miio.getState('batteryLevel');
var fanspeed = this.miio.getState('fanSpeed');

if (this.miio.property('state') == 'charging' && battery !== 100) {
var onoff = false;
var state = 'charging';
} else if (this.miio.property('state') == 'docking' || this.miio.property('state') == 'full' || this.miio.property('state') == 'returning' || this.miio.property('state') == 'waiting' || this.miio.property('state') == 'charging') {
var onoff = false;
var state = 'docked';
} else if (this.miio.property('state') == 'cleaning' || this.miio.property('state') == 'zone-cleaning') {
var onoff = true;
var state = 'cleaning';
} else if (this.miio.property('state') == 'spot-cleaning') {
var onoff = true;
var state = 'spot_cleaning';
} else {
var onoff = false;
var state = 'stopped';
}
if (this.miio.property('state') == 'charging' && battery !== 100) {
var onoff = false;
var state = 'charging';
} else if (this.miio.property('state') == 'docking' || this.miio.property('state') == 'full' || this.miio.property('state') == 'returning' || this.miio.property('state') == 'waiting' || this.miio.property('state') == 'charging') {
var onoff = false;
var state = 'docked';
} else if (this.miio.property('state') == 'cleaning' || this.miio.property('state') == 'zone-cleaning') {
var onoff = true;
var state = 'cleaning';
} else if (this.miio.property('state') == 'spot-cleaning') {
var onoff = true;
var state = 'spot_cleaning';
} else {
var onoff = false;
var state = 'stopped';
}

if (this.getCapabilityValue('onoff') != onoff) {
this.setCapabilityValue('onoff', onoff);
}
if (this.getCapabilityValue('vacuumcleaner_state') != state) {
this.setCapabilityValue('vacuumcleaner_state', state);
}
if (this.getCapabilityValue('measure_battery') != battery) {
this.setCapabilityValue('measure_battery', battery);
}
if (this.getStoreValue('fanspeed') != fanspeed) {
this.setStoreValue('fanspeed', fanspeed);
}
if (this.getStoreValue('state') != this.miio.property('state')) {
this.setStoreValue('state', this.miio.property('state'));
Homey.ManagerFlow.getCard('trigger', 'statusVacuum').trigger(this, {status: this.miio.property('state')}, {})
if (this.getCapabilityValue('onoff') != onoff) {
this.setCapabilityValue('onoff', onoff);
}
if (this.getCapabilityValue('vacuumcleaner_state') != state) {
this.setCapabilityValue('vacuumcleaner_state', state);
}
if (this.getCapabilityValue('measure_battery') != battery) {
this.setCapabilityValue('measure_battery', battery);
}
if (this.getStoreValue('fanspeed') != fanspeed) {
this.setStoreValue('fanspeed', fanspeed);
}
if (this.getStoreValue('state') != this.miio.property('state')) {
this.setStoreValue('state', this.miio.property('state'));
Homey.ManagerFlow.getCard('trigger', 'statusVacuum').trigger(this, {status: this.miio.property('state')}, {})
}
}
catch (error) {
this.log(error);
clearInterval(this.pollingInterval);
this.setUnavailable(Homey.__('unreachable'));
setTimeout(() => {
this.createDevice();
}, 1000 * interval);
}
}
getData();
}, 1000 * interval);
}
}
Expand Down
9 changes: 8 additions & 1 deletion drivers/philips-bulb/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class PhilipsBulbDevice extends Homey.Device {
address: this.getSetting('address'),
token: this.getSetting('token')
}).then(miiodevice => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.miio = miiodevice;

this.miio.on('colorChanged', c => {
Expand Down Expand Up @@ -83,8 +86,12 @@ class PhilipsBulbDevice extends Homey.Device {
this.setAvailable();
}
} catch (error) {
this.setUnavailable(Homey.__('unreachable'));
this.log(error);
clearInterval(this.pollingInterval);
this.setUnavailable(Homey.__('unreachable'));
setTimeout(() => {
this.createDevice();
}, 1000 * interval);
}
}
getData();
Expand Down

0 comments on commit 3ada641

Please sign in to comment.