Skip to content

Commit

Permalink
Release 2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jghaanstra committed Jul 8, 2018
1 parent 39a2878 commit e2d63e8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
12 changes: 7 additions & 5 deletions APPSTORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion docs/obtain_token.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 15 additions & 17 deletions drivers/yeelights/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,47 +53,47 @@ 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]}');
}
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]}');
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/yeelights/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]
}

Expand Down Expand Up @@ -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 + ')';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.xiaomi-miio",
"version": "2.6.5",
"version": "2.7.0",
"description": "Xiaomi Mi Home",
"main": "app.js",
"dependencies": {
Expand Down

0 comments on commit e2d63e8

Please sign in to comment.