Skip to content

Commit

Permalink
Release 2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jghaanstra committed Jan 6, 2018
1 parent 077adda commit cca5fe7
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 11 deletions.
8 changes: 6 additions & 2 deletions APPSTORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This app uses an unofficial library called the [miIO Device Library](https://git

## Supported devices
Below is a list of supported devices and devices that might be supported in the future if there is demand for this. Post a comment in the app store if you would like to see support for a specific device.
* Yeelights: Bulbs Wi-Fi (tested), LED strips (tested), Bedside Lamp II (tested), Ceiling Lights (untested)
* Yeelights: Bulbs Wi-Fi (tested), LED strips (tested), Bedside Lamp II (tested), Ceiling Lights (tested)
* Xiaomi Philips: Light Bulbs (untested), Eyecare Lamp 2 (untested)
* Xiaomi Air Purifiers 2 and Pro (tested)
* Xiamomi Humidifier (untested)
Expand Down Expand Up @@ -45,7 +45,11 @@ For Homey to be able to communicate with devices over the miIO protocol a unique
* Default flow cards for on/off, measure power and meter power capabilities class

## Changelog
### 2017-12-20 -- v2.4.0 - beta
### 2018-01-06 -- v2.4.1
* FIX: some tweaks for the Yeelight JIAOYUE 650 Ceiling Light as it has seperate white (main lamp) and color (background color ring) capabilities
* FIX: probable fix for temperature setting on Philips Light Bulbs

### 2017-12-20 -- v2.4.0
* NEW: added support for the Philips Xiaomi Light Bulbs (untested)
* NEW: added support for the Philips Xiaomi Eyecare Lamp 2 (untested)
* NEW: added support for the Xiaomi Single Power Plug (untested)
Expand Down
6 changes: 5 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class XiaomiMiioApp extends Homey.App {
var color = tinycolor(args.color);
var rgb = color.toRgb();
var colordecimal = (rgb.r * 65536) + (rgb.g * 256) + rgb.b;
args.device.sendCommand(args.device.getData().id, '{"id":1, "method":"set_scene", "params":["color", '+ colordecimal +', '+ args.brightness +']}')
if(args.device.getData().model == 'ceiling4') {
args.device.sendCommand(args.device.getData().id, '{"id":1, "method":"bg_set_scene", "params":["color", '+ colordecimal +', '+ args.brightness +']}')
} else {
args.device.sendCommand(args.device.getData().id, '{"id":1, "method":"set_scene", "params":["color", '+ colordecimal +', '+ args.brightness +']}')
}
})

new Homey.FlowCardAction('yeelightCustomCommand')
Expand Down
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", "yeelight", "yeelights", "purifier", "humidifier", "philips", "eyecare", "powerplug" ],
"nl": [ "Xiaomi", "Mi", "Mi home", "miio", "yeelight", "yeelights", "luchtreiniger", "luchtbevochtiger", "philips", "eyecare", "powerplug" ]
},
"version": "2.4.0",
"version": "2.4.1",
"compatibility": "1.x >=1.5.0",
"author": {
"name": "Jelger Haanstra",
Expand Down
3 changes: 2 additions & 1 deletion drivers/philips-bulb/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class PhilipsBulbDevice extends Homey.Device {
}

onCapabilityLightTemperature(value, opts, callback) {
util.sendCommand('colortemperature', value, this.getSetting('address'), this.getSetting('token'), function(error, result) {
var color_temp = util.denormalize(value, 3000, 5700);
util.sendCommand('colortemperature', color_temp, this.getSetting('address'), this.getSetting('token'), function(error, result) {
if (error) {
callback(error, false);
} else {
Expand Down
31 changes: 26 additions & 5 deletions drivers/yeelights/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ class YeelightDevice extends Homey.Device {
}

onCapabilityDim(value, opts, callback) {
var brightness = value * 100;
if(value == 0) {
var brightness = 1;
} else {
var brightness = value * 100;
}
if(typeof opts.duration !== 'undefined') {
this.sendCommand(this.getData().id, '{"id":1,"method":"set_bright","params":['+ brightness +', "smooth", '+ opts.duration +']}');
} else {
Expand All @@ -75,12 +79,21 @@ class YeelightDevice extends Homey.Device {

var hue = hue_value * 359;
var saturation = saturation_value * 100;
this.sendCommand(this.getData().id, '{"id":1,"method":"set_hsv","params":['+ hue +','+ saturation +', "smooth", 500]}');

if (this.getData().model == 'ceiling4') {
this.sendCommand(this.getData().id, '{"id":1,"method":"bg_set_hsv","params":['+ hue +','+ saturation +', "smooth", 500]}');
} else {
this.sendCommand(this.getData().id, '{"id":1,"method":"set_hsv","params":['+ hue +','+ saturation +', "smooth", 500]}');
}
return Promise.resolve();
}

onCapabilityLightTemperature(value, opts, callback) {
var color_temp = yeelight.denormalize(value, 1700, 6500);
if (this.getData().model == 'ceiling4') {
var color_temp = yeelight.denormalize(value, 2700, 6000);
} else {
var color_temp = yeelight.denormalize(value, 1700, 6500);
}
this.sendCommand(this.getData().id, '{"id":1,"method":"set_ct_abx","params":['+ color_temp +', "smooth", 500]}');
callback(null, value);
}
Expand Down Expand Up @@ -157,7 +170,11 @@ class YeelightDevice extends Homey.Device {
device.setCapabilityValue('dim', dim);
break;
case 'ct':
var color_temp = yeelight.normalize(result.params.ct, 1700, 6500);
if (device.getData().model == 'ceiling4') {
var color_temp = yeelight.normalize(result.params.ct, 2700, 6000);
} else {
var color_temp = yeelight.normalize(result.params.ct, 1700, 6500);
}
device.setCapabilityValue('light_temperature', color_temp);
break;
case 'rgb':
Expand Down Expand Up @@ -199,7 +216,11 @@ class YeelightDevice extends Homey.Device {
var dim = result.result[1] / 100;
var hue = result.result[5] / 359;
var saturation = result.result[6] / 100;
var color_temp = yeelight.normalize(result.result[3], 1700, 6500);
if (device.getData().model == 'ceiling4') {
var color_temp = yeelight.normalize(result.result[3], 2700, 6000);
} else {
var color_temp = yeelight.normalize(result.result[3], 1700, 6500);
}
if(result.result[2] == 2) {
var color_mode = 'temperature';
} else {
Expand Down
10 changes: 10 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,13 @@ exports.sendCommand = function (command, value, address, token) {
})
})
}

exports.normalize = function (value, min, max) {
var normalized = (value - min) / (max - min);
return Number(normalized.toFixed(2));
}

exports.denormalize = function (normalized, min, max) {
var denormalized = ((1 - normalized) * (max - min) + min);
return Number(denormalized.toFixed(0));
}
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.4.0",
"version": "2.4.1",
"description": "Xiaomi Mi Home",
"main": "app.js",
"dependencies": {
Expand Down

0 comments on commit cca5fe7

Please sign in to comment.