diff --git a/APPSTORE.md b/APPSTORE.md index 8957fbf..c90a26f 100644 --- a/APPSTORE.md +++ b/APPSTORE.md @@ -27,5 +27,7 @@ For Homey to be able to communicate with devices over the miIO protocol a unique Xiaomi has released an update for the vacuum cleaners that enables zone cleaning and goto function. Using the action cards that utilize these functions are a bit challenging. If you want to use these cards please read the instructions [here](https://github.com/jghaanstra/com.xiaomi-miio/blob/master/docs/mirobot_zonecleanup.md). ## Changelog -### v2.11.6 - 2019-04-16 -* FIX: update night mode capability when ceiling light is controlled by external source +### v2.11.7 - 2019-05-05 +* FIX: possible fix for app crashes related to connection problems with Yeelights +* FIX: possible fix for app crashes related to connection problems with miio devices +* FIX: fix for app crash when user not defines vacuum cleaner coordinates for zone cleaning correctly diff --git a/app.js b/app.js index 16ede95..6a48e1b 100644 --- a/app.js +++ b/app.js @@ -97,8 +97,12 @@ class XiaomiMiioApp extends Homey.App { .register() .registerRunListener((args, state) => { if (args.device.miio) { - const zones = JSON.parse("[" + args.zones + "]"); - return args.device.miio.activateZoneClean(zones); + try { + const zones = JSON.parse("[" + args.zones + "]"); + return args.device.miio.activateZoneClean(zones); + } catch (error) { + return Promise.reject(new Error('Invalid JSON coordinates ...')); + } } else { return Promise.reject(new Error('Device unreachable, please try again ...')); } @@ -179,9 +183,10 @@ class XiaomiMiioApp extends Homey.App { new Homey.FlowCardAction('humidifierOn') .register() .registerRunListener((args, state) => { - return args.device.miio.setPower(true).then(result => { - return args.device.setCapabilityValue('onoff', true); - }); + return args.device.miio.setPower(true) + .then(result => { + return args.device.setCapabilityValue('onoff', true); + }); }) new Homey.FlowCardAction('humidifierOff') diff --git a/app.json b/app.json index da4ae7d..b907ca8 100644 --- a/app.json +++ b/app.json @@ -10,7 +10,7 @@ "en": [ "Xiaomi", "Mi", "Mi Home", "miio", "vacuumcleaner", "robot", "yeelight", "yeelights", "purifier", "humidifier", "philips", "eyecare", "powerplug", "gateway" ], "nl": [ "Xiaomi", "Mi", "Mi home", "miio", "stofzuiger", "robot", "yeelight", "yeelights", "luchtreiniger", "luchtbevochtiger", "philips", "eyecare", "powerplug", "gateway" ] }, - "version": "2.11.6", + "version": "2.11.7", "compatibility": ">=2.0.0", "author": { "name": "Jelger Haanstra", diff --git a/lib/yeelight.js b/lib/yeelight.js index 1eed004..3af8b8d 100644 --- a/lib/yeelight.js +++ b/lib/yeelight.js @@ -36,11 +36,15 @@ exports.discover = function () { /* listen for advertisements when devices come online and at regular interval */ exports.listenUpdates = function () { - advertisements.bind(1982, function () { - advertisements.addMembership('239.255.255.250'); - advertisements.setBroadcast(true); - advertisements.setMulticastTTL(255); - }); + try { + advertisements.bind(1982, function () { + advertisements.addMembership('239.255.255.250'); + advertisements.setBroadcast(true); + advertisements.setMulticastTTL(255); + }); + } catch(error) { + console.log(error); + } advertisements.on('message', (message, address) => { process.nextTick(function() { diff --git a/node_modules/miio/lib/network.js b/node_modules/miio/lib/network.js index c41e757..c0a8052 100644 --- a/node_modules/miio/lib/network.js +++ b/node_modules/miio/lib/network.js @@ -133,17 +133,21 @@ class Network extends EventEmitter { this._socket = dgram.createSocket('udp4'); // Bind the socket and when it is ready mark it for broadcasting - this._socket.bind(); - this._socket.on('listening', () => { - if (this._socket) { - this._socket.setBroadcast(true); - - const address = this._socket.address(); - this.debug('Network bound to port', address.port); - } else { - this.createSocket(); - } - }); + try { + this._socket.bind(); + this._socket.on('listening', () => { + if (this._socket) { + this._socket.setBroadcast(true); + + const address = this._socket.address(); + this.debug('Network bound to port', address.port); + } else { + this.createSocket(); + } + }); + } catch(ex) { + this.debug(ex); + } // On any incoming message, parse it, update the discovery this._socket.on('message', (msg, rinfo) => { @@ -230,7 +234,7 @@ class Network extends EventEmitter { get socket() { if(! this._socket) { - throw new Error('Network communication is unavailable, device might be destroyed'); + //throw new Error('Network communication is unavailable, device might be destroyed'); // RECREATING SOCKET IF IT'S KILLED, WE NEED IT AVAILABLE AT ALL TIME this.createSocket(); diff --git a/package.json b/package.json index 71bd559..f13f741 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.xiaomi-miio", - "version": "2.11.6", + "version": "2.11.7", "description": "Xiaomi Mi Home", "main": "app.js", "dependencies": {