diff --git a/APPSTORE.md b/APPSTORE.md index d867163..cc0d845 100644 --- a/APPSTORE.md +++ b/APPSTORE.md @@ -12,7 +12,7 @@ Below is a list of supported devices and devices. Post a comment in the [support * Xiamomi Humidifier (tested) * Xiaomi Single Power Plug and Power Strip WiFi version (tested) * Xiaomi PM2.5 Air Monitor (tested) -* Xiaomi Gateway Light - alarm not supported yet and subdevices are supported directly with the Xiaomi ZigBee app (tested) +* Xiaomi Gateway Light - subdevices are supported directly with the Xiaomi ZigBee app (tested) ## Support topic For support please use the official support topic on the forum [here](https://community.athom.com/t/118). @@ -27,15 +27,6 @@ For Homey to be able to communicate with devices over the miIO protocol a unique 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-09-09 - v2.8.3 -* FIX: fixed a bug with powered on|off condition cards for the air purifier and humidifier -* FIX: better error handling when miio device can not connect - -### 2018-09-05 - v2.8.2 -* FIX: fixed bug with return to dock action card for Vacuum Cleaner -* FIX: fixed where the Vacuum Cleaner always shows as charging even thought the battery is full -* IMPROVEMENT: better error catching in polling mechanism for miio devices -* UPDATE: removed support for Philips Eyecare since there is a bug in the miio library for this device (see https://github.com/aholstenson/miio/issues/145) - -### 2018-08-22 - v2.8.1 -* UPDATE: updated app manifest to include id of new forum support topic +### 2018-10-06 - v2.9.0 +* NEW: add homealarm state capability for Xiaomi Gateway (state does not get synced when changing it through the Mi Home app yet) +* FIX: keep custom capability night_mode for specific Yeelights in sync when changed through Yeelight / Mi Home app diff --git a/app.js b/app.js index 5936d57..e33757b 100644 --- a/app.js +++ b/app.js @@ -56,7 +56,11 @@ class XiaomiMiioApp extends Homey.App { new Homey.FlowCardAction('yeelightNightMode') .register() .registerRunListener((args, state) => { - return args.device.triggerCapabilityListener('night_mode', args.value === 'true'); + if(args.mode == 'night') { + return args.device.triggerCapabilityListener('night_mode', true); + } else { + return args.device.triggerCapabilityListener('night_mode', false); + } }) // MI ROBOT: ACTION FLOW CARDS @@ -202,6 +206,18 @@ class XiaomiMiioApp extends Homey.App { }); return Promise.resolve(mode); }) + + // GATEWAY: CONDITION AND ACTION FLOW CARDS + new Homey.FlowCardAction('armGateway') + .register() + .registerRunListener((args, state) => { + var alarm = args.alarm == 'armed' ? true : false; + let mode = args.device.miio.setArming(alarm) + .then(result => { + args.device.setCapabilityValue('homealarm_state', args.alarm); + }); + return Promise.resolve(mode); + }) } } diff --git a/app.json b/app.json index 11da7da..aeaec5b 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,7 @@ { "id": "com.xiaomi-miio", "sdk": 2, + "brandColor": "#FF6801", "name": { "en": "Xiaomi Mi Home", "nl": "Xiaomi Mi Home" @@ -9,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.8.3", + "version": "2.9.0", "compatibility": "1.x >=1.5.0", "author": { "name": "Jelger Haanstra", @@ -43,7 +44,8 @@ "night_mode": { "type": "boolean", "title": { - "en": "Night Mode" + "en": "Night Mode", + "nl": "Nacht modus" }, "getable": true, "setable": true @@ -628,7 +630,8 @@ "dim", "light_hue", "light_saturation", - "measure_luminance" + "measure_luminance", + "homealarm_state" ], "mobile": { "components": [ @@ -636,6 +639,10 @@ "id": "icon", "capabilities": [ "onoff" ] }, + { + "id": "picker", + "capabilities": [ "homealarm_state" ] + }, { "id": "sensor", "capabilities": [ "measure_luminance" ] @@ -1021,7 +1028,7 @@ "id": "yeelightNightMode", "title": { "en": "Toggle Night Mode", - "nl": "Schakel Nacht Modus" + "nl": "Schakel nacht modus" }, "hint": { "en": "Use this card to switch the light between night mode and normal mode", @@ -1029,25 +1036,21 @@ }, "args": [ { - "name": "value", + "name": "mode", "type": "dropdown", - "placeholder": { - "en": "Finish action", - "nl": "Afrondactie" - }, "values": [ { - "id": "false", + "id": "normal", "label": { "en": "Normal Mode", - "nl": "Normale Modus" + "nl": "Normale modus" } }, { - "id": "true", + "id": "night", "label": { "en": "Night Mode", - "nl": "Nacht Modus" + "nl": "Nacht modus" } } ] @@ -1597,6 +1600,44 @@ "nl": "Selecteer Philips Eyecare Lamp" }, "filter": "driver_id=philips-eyecare" + } + ] + }, + { + "id": "armGateway", + "title": { + "en": "Set surveillance mode", + "nl": "Stel toezicht modus in" + }, + "args": [ + { + "name": "alarm", + "type": "dropdown", + "values": [ + { + "id": "armed", + "label": { + "en": "Armed", + "nl": "Ingeschakeld" + } + }, + { + "id": "disarmed", + "label": { + "en": "Disarmed", + "nl": "Uitgeschakeld" + } + } + ] + }, + { + "name": "device", + "type": "device", + "placeholder": { + "en": "Select Gateway", + "nl": "Selecteer Gateway" + }, + "filter": "driver_id=gateway" } ] } diff --git a/drivers/gateway/device.js b/drivers/gateway/device.js index 9aa527e..8738838 100644 --- a/drivers/gateway/device.js +++ b/drivers/gateway/device.js @@ -15,6 +15,7 @@ class GatewayDevice extends Homey.Device { this.registerCapabilityListener('onoff', this.onCapabilityOnoff.bind(this)); this.registerCapabilityListener('dim', this.onCapabilityDim.bind(this)); this.registerMultipleCapabilityListener(['light_hue', 'light_saturation'], this.onCapabilityHueSaturation.bind(this), 500); + this.registerCapabilityListener('homealarm_state', this.onCapabilityAlarm.bind(this)); } onDeleted() { @@ -58,6 +59,14 @@ class GatewayDevice extends Homey.Device { return Promise.resolve(); } + onCapabilityAlarm(value, opts, callback) { + var state = value == 'armed' ? true : false; + + this.miio.setArming(state) + .then(result => { callback(null, value) }) + .catch(error => { callback(error, false) }); + } + // HELPER FUNCTIONS createDevice() { miio.device({ diff --git a/drivers/yeelights/device.js b/drivers/yeelights/device.js index 109d6ef..e4b71f5 100644 --- a/drivers/yeelights/device.js +++ b/drivers/yeelights/device.js @@ -266,6 +266,13 @@ class YeelightDevice extends Homey.Device { device.setCapabilityValue('light_mode', 'color'); } break; + case 'active_mode': + if (result.params.active_mode == 1) { + device.setCapabilityValue('night_mode', true); + } else { + device.setCapabilityValue('night_mode', false); + } + break; default: break; } diff --git a/node_modules/miio/lib/devices/gateway.js b/node_modules/miio/lib/devices/gateway.js index 811c519..26e74d1 100644 --- a/node_modules/miio/lib/devices/gateway.js +++ b/node_modules/miio/lib/devices/gateway.js @@ -67,6 +67,8 @@ const Gateway = Thing.type(Parent => class Gateway extends Parent.with(MiioApi, name: 'illuminance' }); + this.defineProperty('alarm', v => v === 'off'); + this.defineProperty('rgb', { handler: (result, rgba) => { result['rgb'] = { @@ -100,6 +102,16 @@ const Gateway = Thing.type(Parent => class Gateway extends Parent.with(MiioApi, }); } + /** + * Switch the alarm state + */ + setArming(status) { + return this.call('set_arming', [ status ? 'on' : 'off' ], { + refresh: [ 'alarm' ] + }) + .then(MiioApi.checkOk); + } + _report(properties) { Object.keys(properties).forEach(key => { this.setRawProperty(key, properties[key]); diff --git a/package.json b/package.json index e767ffd..721ace5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.xiaomi-miio", - "version": "2.8.3", + "version": "2.9.0", "description": "Xiaomi Mi Home", "main": "app.js", "dependencies": {