Skip to content

Commit

Permalink
Release 2.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jghaanstra committed Jul 24, 2018
1 parent 72e7295 commit 84d9869
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 67 deletions.
15 changes: 8 additions & 7 deletions APPSTORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ This Homey app supports direct control for Yeelights. Before being able to add y
## Adding miIO devices
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.

## Using Target and Zone Cleanup for Xiaomi Mi Robot
Xiaomi has recently released an update for its v1 vacuum that enabled it for the zoned cleaning and goto function that was previously only available to the v2 vacuum. 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
### 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.
### 2018-xx-xx -- v2.8.0
* NEW: support for Yeelight White Tunable (V2) and Yeelight Color V2
* NEW: add action card for Xiaomi Mi Robot to send the robot to a specific target (see instructions)
* NEW: add action card for Xiaomi Mi Robot to do a zone(s) cleanup (see instructions)
* FIX: fix temperature range for Yeelight color bulbs
17 changes: 16 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class XiaomiMiioApp extends Homey.App {
return args.device.triggerCapabilityListener('night_mode', args.value === 'true');
})

// MI ROBOT: CONDITION AND ACTION FLOW CARDS
// MI ROBOT: ACTION FLOW CARDS
new Homey.FlowCardAction('findVacuum')
.register()
.registerRunListener((args, state) => {
Expand All @@ -77,6 +77,21 @@ class XiaomiMiioApp extends Homey.App {
return Promise.resolve(fanspeed);
})

new Homey.FlowCardAction('goToTargetVacuum')
.register()
.registerRunListener((args, state) => {
let target = args.device.miio.goToTarget([args.xcoordinate, args.ycoordinate]);
return Promise.resolve(target);
})

new Homey.FlowCardAction('cleanZoneVacuum')
.register()
.registerRunListener((args, state) => {
var zones = JSON.parse("[" + args.zones + "]");
let zoneclean = args.device.miio.activateZoneClean(zones);
return Promise.resolve(zoneclean);
})

// MI AIR PURIFIER: CONDITION AND ACTION FLOW CARDS
new Homey.FlowCardCondition('poweredAirpurifier')
.register()
Expand Down
70 changes: 69 additions & 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.7.0",
"version": "2.8.0",
"compatibility": "1.x >=1.5.0",
"author": {
"name": "Jelger Haanstra",
Expand Down Expand Up @@ -1199,6 +1199,74 @@
}
]
},
{
"id": "goToTargetVacuum",
"title": {
"en": "Send vacuum cleaner to target",
"nl": "Stuur stofzuiger naar doel"
},
"hint": {
"en": "Enter the x and y coordinates of the target: ex. 25000 and 28000",
"nl": "Voer de x en y coördinaten van het doel in: bv. 25000 en 28000"
},
"args": [
{
"name": "xcoordinate",
"type": "number",
"placeholder": {
"en": "X Coordinate",
"nl": "X coördinaat"
}
},
{
"name": "ycoordinate",
"type": "number",
"placeholder": {
"en": "Y Coordinate",
"nl": "Y coördinaat"
}
},
{
"name": "device",
"type": "device",
"placeholder": {
"en": "Select Mi Robot",
"nl": "Selecteer Mi Robot"
},
"filter": "driver_id=mi-robot"
}
]
},
{
"id": "cleanZoneVacuum",
"title": {
"en": "Start zone cleaning",
"nl": "Start zone schoonmaken"
},
"hint": {
"en": "Takes in an a list of zones and the number of times to clean. Each zone contains an array of 5 values: bottom-left-x, bottom-left-y, top-right-x, top-right-y, number of clean times. Zones example: [26234,26042,26634,26642,1],[26232,25304,27282,25804,2],[26246,24189,27296,25139,2]",
"nl": "Voer een lijst met zones in en het aantal keren om schoon te maken. Elke zone bevat een array met 5 waarden: bottom-left-x, bottom-left-y, top-right-x, top-right-y, number of clean times. Zones voorbeeld: [26234,26042,26634,26642,1],[26232,25304,27282,25804,2],[26246,24189,27296,25139,2]"
},
"args": [
{
"name": "zones",
"type": "text",
"placeholder": {
"en": "Zones",
"nl": "Zones"
}
},
{
"name": "device",
"type": "device",
"placeholder": {
"en": "Select Mi Robot",
"nl": "Selecteer Mi Robot"
},
"filter": "driver_id=mi-robot"
}
]
},
{
"id": "airpurifierOn",
"title": {
Expand Down
Binary file added docs/homezone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions docs/mirobot_zonecleanup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Using the "Go To Target" and "Zone Cleanup" action cards for the Mi Robot.
Below are instructions on how to use the zoned cleaning and goto action cards for the Xiaomi Mi Robot. Credits for this tutorial go out to user ciB on the Home Assistant forum.

## Firmware
This functionality has recently become available for the v1 version of the Xiaomi Mi Robot. Make sure you update your Mi Robot to the latest available firmware using the Mi Home smartphone app. Disclaimer: in some cases this might result in the token being reset which requires you to find your token again.

## Figuring out coordinates on the map
Unfortunately there is no easy way without rooting the device to directly access the map with its coordinates, so you have to do some manual labor. The way the map is created works like this: the starting point of the map (which should be right in front of the dockings station - where your robot starts off at) is somewhere around [25500,25500] and the map is then build around this coordinates.
All you have to do is figure out a grid and then read off the coordinates that you need:
* Step 1: Make sure your docking station is at a fixed position (so your starting point will ALWAYS be the same).
* Step 2: If not yet created, let your robot create a full map of your apartment/flat by starting the cleaning from the Mi Home App.
* Step 3: Use the "go to target" action card to send the robot to places while you have the Mi Home app open. It will then show you where you have send the robot. Increasing the x coordinate will move the robot relative to the starting point to the right (decreasing to the left), increasing the y coordinate will move the robot relative to the starting point to the top (decreasing to the bottom). With some trial and error you will be able to find the right coordinates for places you want to go and for the zones you want to clean.
![Home Location](homezone.png?raw=true)

## Using the "Go To Target" action card
This card requires you to enter the x and y coordinate of a location where you want to go. If you have not figured out the right coordinates yet you should use the Mi Home smartphone app where you can see where your Mi Robot is actually going to go after sending in some coordinates.

## Using the "Zone Cleanup" action card
This action card requires you to enter one or multiple zones for cleaning. A zone takes two coordinates, the first one is the bottom left corner, the other one the top right corner and at the end you can specify the number of times the zone needs to be cleaned. So a single zone would look something like this: [25200, 27500, 27250, 30250, 1]. You can specify multiple zones by seperating them by a comma. So a zone cleanup with two zones would look like this: [25200, 27500, 27250, 30250, 1], [27000, 22250, 28200, 27000, 1].

That's it. Enjoy zone cleaning.
6 changes: 6 additions & 0 deletions drivers/yeelights/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class YeelightDevice extends Homey.Device {
onCapabilityLightTemperature(value, opts, callback) {
if (this.getData().model == 'ceiling4') {
var color_temp = yeelight.denormalize(value, 2700, 6000);
} else if (this.getData().model == 'color') {
var color_temp = yeelight.denormalize(value, 1700, 6500);
} else {
var color_temp = yeelight.denormalize(value, 2700, 6500);
}
Expand Down Expand Up @@ -234,6 +236,8 @@ class YeelightDevice extends Homey.Device {
case 'ct':
if (device.getData().model == 'ceiling4') {
var color_temp = yeelight.normalize(result.params.ct, 2700, 6000);
} else if (device.getData().model == 'color') {
var color_temp = yeelight.normalize(result.params.ct, 1700, 6500);
} else {
var color_temp = yeelight.normalize(result.params.ct, 2700, 6500);
}
Expand Down Expand Up @@ -280,6 +284,8 @@ class YeelightDevice extends Homey.Device {
var saturation = result.result[6] / 100;
if (device.getData().model == 'ceiling4') {
var color_temp = yeelight.normalize(result.result[3], 2700, 6000);
} else if (device.getData().model == 'color') {
var color_temp = yeelight.normalize(result.result[3], 1700, 6500);
} else {
var color_temp = yeelight.normalize(result.result[3], 2700, 6500);
}
Expand Down
3 changes: 3 additions & 0 deletions drivers/yeelights/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const yeelight = require('/lib/yeelight.js');

const typeCapabilityMap = {
'mono' : [ 'onoff', 'dim' ],
'ct' : [ 'onoff', 'dim', 'light_temperature' ],
'color' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode' ],
'stripe' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode' ],
'bslamp' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode' ],
Expand Down Expand Up @@ -38,6 +39,8 @@ class YeelightDriver extends Homey.Driver {
var name = Homey.__('yeelight_bulb_color')+ ' (' + result[i].address + ')';
} else if (result[i].model == 'mono') {
var name = Homey.__('yeelight_bulb_white')+ ' (' + result[i].address + ')';
} else if (result[i].model == 'ct') {
var name = Homey.__('yeelight_bulb_white_v2')+ ' (' + result[i].address + ')';
} else if (result[i].model == 'stripe') {
var name = Homey.__('yeelight_led_strip')+ ' (' + result[i].address + ')';
} else if (result[i].model == 'bslamp') {
Expand Down
29 changes: 29 additions & 0 deletions node_modules/miio/lib/devices/vacuum.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/miio/lib/models.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion node_modules/miio/lib/tokens.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 21 additions & 56 deletions node_modules/miio/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.7.0",
"version": "2.8.0",
"description": "Xiaomi Mi Home",
"main": "app.js",
"dependencies": {
Expand Down

0 comments on commit 84d9869

Please sign in to comment.