From e2d63e86db3136dd986bf69c2c0c663fec95196c Mon Sep 17 00:00:00 2001 From: jghaanstra Date: Sun, 8 Jul 2018 22:17:05 +0200 Subject: [PATCH] Release 2.7.0 --- APPSTORE.md | 12 +++++++----- app.json | 2 +- docs/obtain_token.md | 2 +- drivers/yeelights/device.js | 32 +++++++++++++++----------------- drivers/yeelights/driver.js | 3 +-- package.json | 2 +- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/APPSTORE.md b/APPSTORE.md index a0dcb67..c840f23 100644 --- a/APPSTORE.md +++ b/APPSTORE.md @@ -24,8 +24,10 @@ This Homey app supports direct control for Yeelights. Before being able to add y For Homey to be able to communicate with devices over the miIO protocol a unique device token needs to be obtained. Technical knowledge is needed for retrieving these tokens. If your are not to tech-savvy using this app for any other devices than the Yeelights might be challenging. See the instructions [here](https://github.com/jghaanstra/com.xiaomi-miio/blob/master/docs/obtain_token.md) on retrieving device tokens. ## Changelog -### 2018-06-05 -- v2.6.5 -* NEW: add support for Yeelight Desk Lamp -* FIX: remove color capabilities for regular Yeelight ceiling lamp -* FIX: fix type-o in temperature range for Yeelight ceiling lamp -* FIX: fixed issues with color temperature for Xiaomi Philips Light Bulbs +### 2018-07-08 -- v2.7.0 +* Merged Pull Requests by Bas Kiers + * FIX: Yeelights connection issues (sending commands while Yeelight is connecting and sending multiple commands) + * NEW: Add support for Yeelight with model identifier ceiling1 + * NEW: Add action card for setting night mode, available for (some) Yeelight ceiling lights + * NEW: Auto toggle nightmode when setting brightness to 0 or 100 twice within 5 seconds +* UPDATE: Update docs, the latest version of the Mi Home smartpone app dont hold the token in the database anymore. diff --git a/app.json b/app.json index a26982a..4dab94f 100644 --- a/app.json +++ b/app.json @@ -9,7 +9,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.6.5", + "version": "2.7.0", "compatibility": "1.x >=1.5.0", "author": { "name": "Jelger Haanstra", diff --git a/docs/obtain_token.md b/docs/obtain_token.md index f13505b..8f79941 100644 --- a/docs/obtain_token.md +++ b/docs/obtain_token.md @@ -28,7 +28,7 @@ While running this you have to listen with Wireshark or tcpdump for UDP packages Extract the last 16 bytes of the answer and convert them to a (32 characters) hexadecimal string using `xxd -p`. ## Method 3 - Obtain Mi Home device token for devices that hide their tokens after setup -Use these methods to obtain the device token for devices that hide their tokens after setup in the Mi Home App (like the Mi Robot Vacuum Cleaner with firmware 3.3.9_003077 or higher). +Use these methods to obtain the device token for devices that hide their tokens after setup in the Mi Home App (like the Mi Robot Vacuum Cleaner with firmware 3.3.9_003077 or higher). The latest versions of the Mi Home smartphone app dont hold the token anymore so before you begin with any of these methods you will need to install an older version of the smartphone app. Version 5.0.19 works for sure and perhaps maybe even some newer version as well. Android users can find older version of the app [here](https://www.apkmirror.com/apk/xiaomi-inc/mihome/). ### Android users #### Rooted Android Phones diff --git a/drivers/yeelights/device.js b/drivers/yeelights/device.js index 2920237..e3e83a3 100644 --- a/drivers/yeelights/device.js +++ b/drivers/yeelights/device.js @@ -53,35 +53,35 @@ class YeelightDevice extends Homey.Device { const initialNightModeValue = this.getCapabilityValue('night_mode'); await this.triggerCapabilityListener('night_mode', true); // If we think we really toggled the night mode we will set the brightness of night mode to 100 - if(initialNightModeValue === false) { + if (initialNightModeValue === false) { value = 1; overWriteDimVal = 1; brightness = 100; } this.dimMinTime = 0; - }else { + } else { this.dimMinTime = Date.now(); } - }else if (value === 1){ + } else if (value === 1) { if (this.dimMaxTime + 5000 > Date.now()) { const initialNightModeValue = this.getCapabilityValue('night_mode'); await this.triggerCapabilityListener('night_mode', false); // If we think we really toggled the night mode we will set the brightness of normal mode to 1 - if(initialNightModeValue === true) { + if (initialNightModeValue === true) { value = 0; overWriteDimVal = 0; brightness = 1; } this.dimMaxTime = 0; - }else { + } else { this.dimMaxTime = Date.now(); } - }else { + } else { this.dimMinTime = 0; this.dimMaxTime = 0; } - if(typeof opts.duration !== 'undefined') { + if (typeof opts.duration !== 'undefined') { this.sendCommand(this.getData().id, '{"id":1,"method":"set_bright","params":['+ brightness +', "smooth", '+ opts.duration +']}'); } else { this.sendCommand(this.getData().id, '{"id":1,"method":"set_bright","params":['+ brightness +', "smooth", 500]}'); @@ -89,11 +89,11 @@ class YeelightDevice extends Homey.Device { callback(null, value); // "hack" to fix dim bar behaviour in the homey UI - if(overWriteDimVal !== undefined) { + if (overWriteDimVal !== undefined) { this.setCapabilityValue('dim', overWriteDimVal); } } - + onCapabilityNightMode(value, opts, callback) { if (value) { this.sendCommand(this.getData().id, '{"id": 1, "method": "set_power", "params":["on", "smooth", 500, 5]}'); @@ -204,7 +204,6 @@ class YeelightDevice extends Homey.Device { yeelights[id].socket.on('data', (message, address) => { clearTimeout(yeelights[id].timeout); clearTimeout(yeelights[id].reconnect); - yeelights[id].timeout = null; yeelights[id].reconnect = null; if(!device.getAvailable()) { @@ -318,13 +317,12 @@ class YeelightDevice extends Homey.Device { } else { yeelights[id].socket.write(command + '\r\n'); - if (yeelights[id].timeout === null) { - yeelights[id].timeout = setTimeout(() => { - if (yeelights[id].connected === true && yeelights[id].socket !== null) { - yeelights[id].socket.emit('error', new Error('Error sending command')); - } - }, 6000); - } + clearTimeout(yeelights[id].timeout); + yeelights[id].timeout = setTimeout(() => { + if (yeelights[id].connected === true && yeelights[id].socket !== null) { + yeelights[id].socket.emit('error', new Error('Error sending command')); + } + }, 6000); } } diff --git a/drivers/yeelights/driver.js b/drivers/yeelights/driver.js index fb54875..f6734c8 100644 --- a/drivers/yeelights/driver.js +++ b/drivers/yeelights/driver.js @@ -9,7 +9,7 @@ const typeCapabilityMap = { 'stripe' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode' ], 'bslamp' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode' ], 'ceiling' : [ 'onoff', 'dim', 'light_temperature', 'light_mode', 'night_mode' ], - 'ceiling4' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode' ], + 'ceiling4' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode', 'night_mode' ], 'desklamp' : [ 'onoff', 'dim', 'light_temperature', 'light_mode' ] } @@ -44,7 +44,6 @@ class YeelightDriver extends Homey.Driver { var name = Homey.__('yeelight_bedside_lamp')+ ' (' + result[i].address + ')'; } else if (result[i].model.startsWith('ceiling')) { if(result[i].model !== 'ceiling4') { - // Default the ceiling light to the default ceiling light. result[i].model = 'ceiling'; } var name = Homey.__('yeelight_ceiling_light')+ ' (' + result[i].address + ')'; diff --git a/package.json b/package.json index 3f9e5ed..81f138e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.xiaomi-miio", - "version": "2.6.5", + "version": "2.7.0", "description": "Xiaomi Mi Home", "main": "app.js", "dependencies": {