From 8f77435686b73768e6a7565f4bed2ce29f71f4ba Mon Sep 17 00:00:00 2001 From: jghaanstra Date: Sat, 23 Dec 2017 10:20:02 +0100 Subject: [PATCH] Beta release 2.4.0 --- APPSTORE.md | 38 ++- app.js | 26 ++ app.json | 311 +++++++++++++++++- docs/obtain_token.md | 47 ++- drivers/mi-power-plug/assets/icon.svg | 18 + drivers/mi-power-plug/assets/images/large.jpg | Bin 0 -> 7699 bytes drivers/mi-power-plug/assets/images/small.jpg | Bin 0 -> 851 bytes drivers/mi-power-plug/device.js | 66 ++++ drivers/mi-power-plug/driver.js | 22 ++ drivers/mi-power-plug/pair/start.html | 142 ++++++++ drivers/philips-bulb/assets/icon.svg | 232 +++++++++++++ drivers/philips-bulb/assets/images/large.jpg | Bin 0 -> 9662 bytes drivers/philips-bulb/assets/images/small.jpg | Bin 0 -> 776 bytes drivers/philips-bulb/device.js | 92 ++++++ drivers/philips-bulb/driver.js | 22 ++ drivers/philips-bulb/pair/start.html | 142 ++++++++ drivers/philips-eyecare/assets/icon.svg | 100 ++++++ .../philips-eyecare/assets/images/large.jpg | Bin 0 -> 7629 bytes .../philips-eyecare/assets/images/small.jpg | Bin 0 -> 741 bytes drivers/philips-eyecare/device.js | 80 +++++ drivers/philips-eyecare/driver.js | 22 ++ drivers/philips-eyecare/pair/start.html | 146 ++++++++ drivers/yeelights/assets/bslamp.svg | 64 +--- drivers/yeelights/assets/ceiling.svg | 52 ++- drivers/yeelights/assets/ceiling4.svg | 32 ++ drivers/yeelights/driver.js | 24 +- lib/util.js | 103 ++++++ locales/en.json | 7 + locales/nl.json | 7 + package.json | 2 +- 30 files changed, 1687 insertions(+), 110 deletions(-) create mode 100644 drivers/mi-power-plug/assets/icon.svg create mode 100644 drivers/mi-power-plug/assets/images/large.jpg create mode 100644 drivers/mi-power-plug/assets/images/small.jpg create mode 100644 drivers/mi-power-plug/device.js create mode 100644 drivers/mi-power-plug/driver.js create mode 100644 drivers/mi-power-plug/pair/start.html create mode 100644 drivers/philips-bulb/assets/icon.svg create mode 100644 drivers/philips-bulb/assets/images/large.jpg create mode 100644 drivers/philips-bulb/assets/images/small.jpg create mode 100644 drivers/philips-bulb/device.js create mode 100644 drivers/philips-bulb/driver.js create mode 100644 drivers/philips-bulb/pair/start.html create mode 100644 drivers/philips-eyecare/assets/icon.svg create mode 100644 drivers/philips-eyecare/assets/images/large.jpg create mode 100644 drivers/philips-eyecare/assets/images/small.jpg create mode 100644 drivers/philips-eyecare/device.js create mode 100644 drivers/philips-eyecare/driver.js create mode 100644 drivers/philips-eyecare/pair/start.html create mode 100644 drivers/yeelights/assets/ceiling4.svg diff --git a/APPSTORE.md b/APPSTORE.md index c9976a3..48d2cc4 100644 --- a/APPSTORE.md +++ b/APPSTORE.md @@ -5,12 +5,11 @@ 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. -* Yeelight Bulbs Wi-Fi (tested) -* Yeelight LED strips (tested) -* Yeelight Ceiling Light (untested) -* Yeelight Bedside Lamp II (untested) -* Air Purifiers 2 and Pro (tested) -* Humidifier (untested) +* Yeelights: Bulbs Wi-Fi (tested), LED strips (tested), Bedside Lamp II (tested), Ceiling Lights (untested) +* Xiaomi Philips: Light Bulbs (untested), Eyecare Lamp 2 (untested) +* Xiaomi Air Purifiers 2 and Pro (tested) +* Xiamomi Humidifier (untested) +* Xiaomi Single Power Plug WiFi version (untested) * NOT SUPPORTED ANYMORE: Robot Vacuum Cleaner (commands time out with latest firmware) * NOT SUPPORTED: Yeelight Desk Lamp * NOT SUPPORTED: Smart Socket Plug and Power Strips @@ -21,27 +20,36 @@ Below is a list of supported devices and devices that might be supported in the For support please use the official support topic on the forum [here](https://forum.athom.com/discussion/3295/). ## Adding Yeelights -This Homey app supports direct control for Yeelights. Before being able to add your Yeelights as devices in Homey you will need to enable the "Developer Mode". You can do this by using the official Yeelight app on your smartphone (not the Xiaomi Mi Home app but the actual Yeelight app). In this app go into the settings of your bulb and you will see a menu item called Developer Mode. This contains a toggle to enable the developer mode. After enabling this the Homey app will be able to autodiscover your bulb when adding it as new device. +This Homey app supports direct control for Yeelights. Before being able to add your Yeelights as devices in Homey you will need to enable the "Developer Mode" or "LAN control" in the official Yeelight app. You can do this by using the official Yeelight app on your smartphone (not the Xiaomi Mi Home app but the actual Yeelight app). In this app go into the settings of your bulb and you will see a menu item called Developer Mode. This contains a toggle to enable the developer mode. After enabling this the Homey app will be able to autodiscover your bulb when adding it as new device. -## Adding miIO devices (Air Purifier and Humidifier) -For Homey to be able to communicate with devices over the miIO protocol a unique device token needs to be obtained. Some technical skills are needed for retrieving these tokens. If your are not to tech-savvy using this app for any other device than the Yeelights might be challenging. See the instructions below. - -* [Air Purifier and Humidifier](https://github.com/jghaanstra/com.xiaomi-miio/blob/master/docs/obtain_token.md). +## Adding miIO devices +For Homey to be able to communicate with devices over the miIO protocol a unique device token needs to be obtained. Some technical skills are 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). ## Supported Cards -### Yeelight Bulbs Wi-Fi +### Yeelights * Default flow cards for light capabilities class * [ACTIONS] Change brightness over time, Temperature/brightness scene, Color/brightness scene, Custom command (advanced), Set default on state -### Mi Air Purifiers +### Xiaomi Philips Light Bulbs +* Default flow cards for light capabilities class + +### Xiaomi Mi Air Purifiers * [CONDITIONS] Powered * [ACTIONS] Power on/off, Set speed -### Mi Humidifiers +### Xiaomi Mi Humidifiers * [CONDITIONS] Powered * [ACTIONS] Power on/off, Set speed +### Xiaomi Single Power Plug +* Default flow cards for on/off, measure power and meter power capabilities class + ## Changelog +### 2017-12-20 -- v2.4.0 - beta +* 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) + ### 2017-11-30 -- v2.3.2 * FIX: added a keep-alive to Yeelight connections to maintain the connection over time * FIX: fixed pairing wizard for Humidifier and Purifier @@ -49,7 +57,7 @@ For Homey to be able to communicate with devices over the miIO protocol a unique ### 2017-11-06 -- v2.3.1 * UPDATE: code rewrite for SDK2 * UPDATE: made use of official donation button feature of Homey app store -* REMOVED: driver for the Mi Robot Vacuum Cleaner since it's not working anymore with the latest firmware update of the cleaner (if you still want to use/try it you can do a local install from the [beta branch on GitHub](https://github.com/jghaanstra/com.xiaomi-miio/tree/beta) ) +* REMOVED: driver for the Mi Robot Vacuum Cleaner since it's not working anymore with the latest firmware update of the cleaner (if you still want to use/try it you can do a local install from an archive [beta branch on GitHub](https://github.com/jghaanstra/com.xiaomi-miio/releases/tag/2.3.1-beta) ) * NEW: changed Yeelight driver to support Yeelight LED strip (require repairing of **ALL** Yeelight devices) * NEW: added extra action cards for Yeelights: Change brightness over time, Custom command (advanced), Set default on state, Temperature/brightness scene, Color/brightness scene * NEW: added support for the default dim over time action card for Yeelights diff --git a/app.js b/app.js index bbad54a..d763b54 100644 --- a/app.js +++ b/app.js @@ -140,6 +140,32 @@ class XiaomiMiioApp extends Homey.App { return Promise.reject(error); }) }) + + // PHILIPS EYECARE LAMP: CONDITION AND ACTION FLOW CARDS + new Homey.FlowCardAction('enableEyecare') + .register() + .registerRunListener((args, state) => { + var eyecare = args.eyecare == 'on' ? true : false; + util.sendCommand('eyecare', eyecare, args.device.getSetting('address'), args.device.getSetting('token')) + .then(result => { + return Promise.resolve(result); + }) + .catch(error => { + return Promise.reject(error); + }) + }) + + new Homey.FlowCardAction('modeEyecare') + .register() + .registerRunListener((args, state) => { + util.sendCommand('mode', args.mode, args.device.getSetting('address'), args.device.getSetting('token')) + .then(result => { + return Promise.resolve(result); + }) + .catch(error => { + return Promise.reject(error); + }) + }) } } diff --git a/app.json b/app.json index 4406a95..e548d41 100644 --- a/app.json +++ b/app.json @@ -6,10 +6,10 @@ "nl": "Xiaomi Mi Home" }, "tags": { - "en": [ "Xiaomi", "Mi", "Mi Home", "yeelight", "yeelights", "purifier", "humidifier" ], - "nl": [ "Xiaomi", "Mi", "Mi home", "yeelight", "yeelights", "luchtreiniger", "luchtbevochtiger" ] + "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.3.2", + "version": "2.4.0", "compatibility": "1.x >=1.5.0", "author": { "name": "Jelger Haanstra", @@ -78,6 +78,133 @@ } ] }, + { + "id": "philips-bulb", + "name": { + "en": "Philips Light Bulb", + "nl": "Philips Light Bulb" + }, + "images": { + "large": "drivers/philips-bulb/assets/images/large.jpg", + "small": "drivers/philips-bulb/assets/images/small.jpg" + }, + "class": "light", + "capabilities": [ + "onoff", + "dim", + "light_temperature" + ], + "pair": [ + { + "id": "start" + } + ], + "settings": [ + { + "type": "group", + "label": { + "en": "Philips Light Bulb Settings", + "nl": "Philips Light Bulb Instellingen" + }, + "children": [ + { + "id": "address", + "type": "text", + "value": "0.0.0.0", + "label": { + "en": "IP Address", + "nl": "IP Adres" + } + }, + { + "id": "token", + "type": "text", + "value": "", + "label": { + "en": "Philips Light Bulb Token", + "nl": "Philips Light Bulb Token" + } + }, + { + "id": "polling", + "type": "number", + "value": 10, + "attr": { + "min": 5, + "max": 3600 + }, + "label": { + "en": "Philips Light Bulb Polling", + "nl": "Philips Light Bulb Polling" + } + } + ] + } + ] + }, + { + "id": "philips-eyecare", + "name": { + "en": "Philips Eyecare Lamp", + "nl": "Philips Eyecare Lamp" + }, + "images": { + "large": "drivers/philips-eyecare/assets/images/large.jpg", + "small": "drivers/philips-eyecare/assets/images/small.jpg" + }, + "class": "light", + "capabilities": [ + "onoff", + "dim" + ], + "pair": [ + { + "id": "start" + } + ], + "settings": [ + { + "type": "group", + "label": { + "en": "Philips Eyecare Lamp Settings", + "nl": "Philips Eyecare Lamp Instellingen" + }, + "children": [ + { + "id": "address", + "type": "text", + "value": "0.0.0.0", + "label": { + "en": "IP Address", + "nl": "IP Adres" + } + }, + { + "id": "token", + "type": "text", + "value": "", + "label": { + "en": "Philips Light Bulb Token", + "nl": "Philips Light Bulb Token" + } + }, + { + "id": "polling", + "type": "number", + "value": 10, + "attr": { + "min": 5, + "max": 3600 + }, + "label": { + "en": "Philips Light Bulb Polling", + "nl": "Philips Light Bulb Polling" + } + } + ] + } + ] + }, { "id": "mi-airpurifier", "name": { @@ -149,6 +276,10 @@ "id": "polling", "type": "number", "value": 60, + "attr": { + "min": 5, + "max": 3600 + }, "label": { "en": "Mi Air Purifier Polling", "nl": "Mi Luchtreiniger Polling" @@ -225,6 +356,10 @@ "id": "polling", "type": "number", "value": 60, + "attr": { + "min": 5, + "max": 3600 + }, "label": { "en": "Mi Humidifier Polling", "nl": "Mi Luchtbevochtiger Polling" @@ -233,6 +368,86 @@ ] } ] + }, + { + "id": "mi-power-plug", + "name": { + "en": "Mi Power Plug", + "nl": "Mi Power Plug" + }, + "images": { + "large": "drivers/mi-power-plug/assets/images/large.jpg", + "small": "drivers/mi-power-plug/assets/images/small.jpg" + }, + "class": "sensor", + "capabilities": [ + "onoff", + "measure_power", + "meter_power" + ], + "mobile": { + "components": [ + { + "id": "icon", + "capabilities": [ "onoff" ] + }, + { + "id": "sensor", + "capabilities": [ "measure_power" ] + }, + { + "id": "sensor", + "capabilities": [ "meter_power" ] + } + ] + }, + "pair": [ + { + "id": "start" + } + ], + "settings": [ + { + "type": "group", + "label": { + "en": "Mi Power Plug Settings", + "nl": "Mi Power Plug Instellingen" + }, + "children": [ + { + "id": "address", + "type": "text", + "value": "0.0.0.0", + "label": { + "en": "IP Address", + "nl": "IP Adres" + } + }, + { + "id": "token", + "type": "text", + "value": "", + "label": { + "en": "Mi Power Plug Token", + "nl": "Mi Power Plug Token" + } + }, + { + "id": "polling", + "type": "number", + "value": 30, + "attr": { + "min": 5, + "max": 3600 + }, + "label": { + "en": "Mi Power Plug Polling", + "nl": "Mi Power Plug Polling" + } + } + ] + } + ] } ], "flow": { @@ -673,6 +888,96 @@ "nl": "Selecteer Mi Luchtbevochtiger" }, "filter": "driver_id=mi-humidifier" + } + ] + }, + { + "id": "enableEyecare", + "title": { + "en": "Switch Eyecare", + "nl": "Eyecare schakelen" + }, + "args": [ + { + "name": "eyecare", + "type": "dropdown", + "values": [ + { + "id": "on", + "label": { + "en": "On", + "nl": "Aan" + } + }, + { + "id": "off", + "label": { + "en": "Off", + "nl": "Uit" + } + }, + { + "id": "phone", + "label": { + "en": "Phone", + "nl": "Telefoon" + } + } + ] + }, + { + "name": "device", + "type": "device", + "placeholder": { + "en": "Select Philips Eyecare Lamp", + "nl": "Selecteer Philips Eyecare Lamp" + }, + "filter": "driver_id=philips-eyecare" + } + ] + }, + { + "id": "modeEyecare", + "title": { + "en": "Set Mode", + "nl": "Stel modus in" + }, + "args": [ + { + "name": "mode", + "type": "dropdown", + "values": [ + { + "id": "study", + "label": { + "en": "Study", + "nl": "Studeer" + } + }, + { + "id": "reading", + "label": { + "en": "Reading", + "nl": "Lezen" + } + }, + { + "id": "phone", + "label": { + "en": "Phone", + "nl": "Telefoon" + } + } + ] + }, + { + "name": "device", + "type": "device", + "placeholder": { + "en": "Select Philips Eyecare Lamp", + "nl": "Selecteer Philips Eyecare Lamp" + }, + "filter": "driver_id=philips-eyecare" } ] } diff --git a/docs/obtain_token.md b/docs/obtain_token.md index fdffcc0..27dfb96 100644 --- a/docs/obtain_token.md +++ b/docs/obtain_token.md @@ -1,8 +1,8 @@ # Obtain Mi Home device token -Use these methods to obtain the device token for the Mi Robot Vacuum Cleaner with firmware lower as 3.3.9_003077, the Air Purifier and the Humidifier. If your Mi Vacuum Robot Cleaner is on firmware 3.3.9_003077 or higher you will need to follow the steps as described [here](https://github.com/jghaanstra/com.xiaomi-miio/blob/master/docs/obtain_token_mirobot_new.md). +Use these methods to obtain the device token for the supported miio devices. ## Method 1 - Nodejs Command Line Tool from the miIO Device library -The author of the miIO Device Library which is used by this Homey app has also created a nodejs command line tool for retrieving device tokens. Please follow the steps in [these instructions](https://github.com/aholstenson/miio/blob/master/docs/management.md) to retrieve the token for the Air Purifier or Humidifier. Be aware that the Mi Robot Vacuum Cleaner hides it's token when it has been setup. Retrieving tokens from the Mi Robot Vacuum Cleaner require a reset of the device as described [here](https://github.com/aholstenson/miio/blob/master/docs/management.md#getting-the-token-of-a-device). +The author of the miIO Device Library which is used by this Homey app has also created a nodejs command line tool for retrieving device tokens. Please follow the steps in [these instructions](https://github.com/aholstenson/miio/blob/master/docs/management.md) to retrieve the token for the supported miio devices. Be aware that some devices hide their token after the device has been setup in the Mi Home app. Retrieving tokens for these devices will not work with this method but require method 3. ## Method 2 - Packet Sender Tool During setup of Mi Home devices the device tokens an be retrieved by sending a ping command to the device. This method uses a tool called Packet Sender which you will need to download. Choose the portable version which does not require installation. @@ -16,3 +16,46 @@ During setup of Mi Home devices the device tokens an be retrieved by sending a p * Protocol dropdown: UDP * Click send and the device will respond with an answer which contains the unique device token. In the last 16 bytes (32 characters) of the devices response is the device token. Copy and save it somewhere. * Disconnect your computer from the devices network, you can now use the Mi Home app to setup the device and connect it to your Wi-Fi network. + +## 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). + +### Android users +#### Rooted Android Phones +* Setup your Android device with the Mi Home app +* Install [aSQLiteManager](https://play.google.com/store/apps/details?id=dk.andsen.asqlitemanager) on your phone +* Use a file browser with granted root privilege and browse to /data/data/com.xiaomi.smarthome/databases/ +* Copy miio2.db to an accessable location +* Open your copy of miio2.db with aSQLiteManager and execute the query "select token from devicerecord where localIP is '192.168.0.1'" where you replace the IP address with the IP address of the device you want to get the token from. It will show you the 32 character device token for your Mi Home device. + +#### Non-Rooted Android Phones +* Setup your Android device with the Mi Home app +* Enable developer mode and USB debugging on your phone and connect it to your computer +* Get the ADB tool for Windows: https://developer.android.com/studio/releases/platform-tools.html +* Create a backup of the Mi Home app: .\adb backup -noapk com.xiaomi.smarthome -f backup.ab +* On your phone you must confirm the backup. Do not enter any password and press button to make the backup +* Get ADB Backup Extractor and install it: https://sourceforge.net/projects/adbextractor/ +* Extract all files from the backup on your computer: java.exe -jar ../android-backup-extractor/abe.jar unpack backup.ab backup.tar +* Unzip the ".tar" file +* Open /com.xiaomi.smarthome/database/miio2.db with a SQLite browser (for instance http://sqlitebrowser.org/) +* Execute the query "select token from devicerecord where localIP is '192.168.0.1'" where you replace the IP address with the IP address of the Mi Home device you want to get the token from. It will show you the 32 character device token for your Mi Home device. + +### iOS users +### Non-Jailbroken iOS users +* Setup your iOS device with the Mi Home app +* Create an unencrypted backup of your iOS device on your computer using iTunes. In case you are unable to disable encryption you probably have a profile preventing this that enforces certain security policies (like work related accounts). Delete these profiles or use another iOS device to continu. +* Install iBackup Viewer from [here](http://www.imactools.com/iphonebackupviewer/). +* Navigate to your BACKUPS and find the name of your iOS device in the list. Open this backup by clicking the triangle in front of it and then click on raw data. +* Sort the view by name and find the folder com.xiaomi.mihome and highlight it (it's somewhere at the end). After highlighting it click on the cockwheel above the results and select "Save selected files" from here and choose a location to save the files. +* Navigate to the com.xiaomi.mihome folder which you just saved somewhere and inside this folder navigate to the /Documents/ subfolder. In this folder there is a file named _mihome.sqlite where your userid is specific for your account. +* Open this file with a SQLite browser (for instance http://sqlitebrowser.org/) +* Execute the query "select ZTOKEN from ZDEVICE where ZLOCALIP is '192.168.0.1'" where you replace the IP address with the IP address of the Mi Home device you want to get the token from. It will show you the 32 character device token for your Mi Home device. + +## Jailbroken iOS users +* Setup your iOS device with the Mi Home app +* Use something like Forklift sFTP to connect to your iOS device and copy this file to your computer: /var/mobile/Containers/Data/Application/514106F3-C854-45E9-A45C-119CB4FFC235/Documents/USERID_mihome.sqlite +** username: root +** IP address: your phones IP address +** password: alpine (unless you changed it something else) +* Open this file with a SQLite browser (for instance http://sqlitebrowser.org/) +* Execute the query "select ZTOKEN from ZDEVICE where ZLOCALIP is '192.168.0.1'" where you replace the IP address with the IP address of the Mi Home device you want to get the token from. It will show you the 32 character device token for your Mi Home device. diff --git a/drivers/mi-power-plug/assets/icon.svg b/drivers/mi-power-plug/assets/icon.svg new file mode 100644 index 0000000..916094c --- /dev/null +++ b/drivers/mi-power-plug/assets/icon.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/drivers/mi-power-plug/assets/images/large.jpg b/drivers/mi-power-plug/assets/images/large.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b0c54107be98f393260122ea97598cea141eee59 GIT binary patch literal 7699 zcmeHLc|6ox|3BYZZDS7^#@tfsDdEx}+swViREoOyT8k-_bwVLz8Roe+OEK+Q&5bN& zD{EyLr6ft#Y?p~_AqFG6=R2sUZauHx^Uw3&?|eDueD?P_-*Z0a%y*$_feR#em~J-( z5Cj1#{D6g4@H4=mP$)DCgGOV7G4Q{r5C$V8DkdT#Dk35#DYjT7#l$5fCB(&KWMpM! zWR&oDyb|$q5jcUcSS(Hqrywb*ptwS6h2m%7f7@B$04X7892!SLQUDY zN>_X@-@F*ZcufBh0ACd1;1Pq}oE+!MIZmP5@xTwb)%GsK`%7IK-@JN+;H5n=rWHCr zHStoH%S_q$e+MEexNX*=wiF#w`bFEdy{?b};5A7U*a@{jTH5c0c|V%DBY3G*DqcEg zj#%iS2Qp$Gk}$dTo%wCJB}IYqcZ+8Ik#`w2e5zh3@o(}vLc$ugMkDC2SanZj6V9f; ziN7LO)k)!>8@A>57A1vFhqJ$u0l;u1>~zZGy=fx+t|1o@H-_f?P2md?s!l7e?;c}$ zg_FPFE_N0BM<@MSLZXo+^JLY(3qR8k;MRA%c7^|q2mmEpda&`W2mRfAveB%*`(-7E>_X~)o*#YR{3-pQcS?+J zT_HB>InkUR^M7HQ^be0a_G9yezg1e|VB=HsNv;zZ;x{W3`CKm1^V}+^E?z|kS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x^hTA%lUk# zNcprvPw+b>#f;TuzFN7%6^?@`dR-Rtltdc33+QA3*L@D0#)7c4gP4oYa2rl5nrgbr zqC44zzsd_x+Y#j=P=lffKU6ry06`&wPbCs1$k;Ct=Rsn<>{Y~hGK~3^i&(EL;!>Gd zujG0?%J#=1yCrCQy-p%bECz)}AeH0^A?6hjpS)DgJDAS@bP-A$cuPu1O|KjYft4Q~^Z%6ko8NB2gYNf@~0(vVJrA z2qXCq5r0}*C)!yM-S)A_D`4e?Fcd~|Q2t=)i3c)VL_1I`MHfoiX(4JNV@OTG-DtsTl!T1~y{((rug@H3+c*G;bT6QLJgAN=thHT{> zZm4PYhtLRTB#a=r`Z4kevXr4FNl;LK8}6h)kc68cO?#F&+5Upe3iJbb8e!+c@SyMr z3Xui7hYz7I3Id?0a2z~>ggO?kPf=pWSn5M?O@?d6G3Ys#2sa!x*q=Vdka5$}Vk07e z-2KU;ACMMYT4D5mFCIbwm~uSe6axn)p$3JT;2>0`EbKZw8BbPX-?TJaC#XqC!4xo> ca10pY;x+4Qd|&y+aOmLs&sS>ydt#yaU;N`pCjbBd literal 0 HcmV?d00001 diff --git a/drivers/mi-power-plug/assets/images/small.jpg b/drivers/mi-power-plug/assets/images/small.jpg new file mode 100644 index 0000000000000000000000000000000000000000..89ae70ff65adb8998a61c4a2aef1909168cb8010 GIT binary patch literal 851 zcmex=i3*BJ!6k`h{6D}T z$id*v;LXe^$iO7X$SlbC{|JLL0|OH?$h8Q-!pO|Z#Kr-X)DvJ}WM*PzW@KlDN;3jg zvk0;ZDH=KoD+MO9i6|Qd6*d|>B^6Bssux8y2&4yOhnOISIHTbITMRtRK;s0N1sUua zel2Baa8MB7U}0heG1@ImmmW`O6u)}PKR@F`gJ?0IqvMTr^|~AqZE2@WF7zJa1}kOy zx_(RI{vZ~4mBQ{54-Wq6-F}hXgGJ0mMSSY4X?gdRCp0_uXWx>!TsGH<6J)x;>blIe zhf5rvEjwVyX?P;*$%>pWbAxqyD>mO^Ta$6eB5ixG$ibZ4b<5Wr`^VW!$4$QNadl8RIkBNi`ukc@Zw#&c)XrU6-4$<@hQyI-`Eus=ft1$Kvc0 z%`-mMUWkJDW63;$)O*jKPm!FVrm0%L-`yZPOCxK(zjE}}2EN2UTTjTWT9s>&a4Kb1 zcxs#2pL3sTncbEw*mvEG!=zyY^C7;r6RHdij;_gTdG{?&;aJdcZQD-=adR`Vou2~2 zPGv*~syfI^IY>R9o7`UhCV=|5^mum_=$7 gE_Ai_JY@FmVUfMbvH%#btW8V@8B>4>q51z!0P`0V_y7O^ literal 0 HcmV?d00001 diff --git a/drivers/mi-power-plug/device.js b/drivers/mi-power-plug/device.js new file mode 100644 index 0000000..f41e03e --- /dev/null +++ b/drivers/mi-power-plug/device.js @@ -0,0 +1,66 @@ +'use strict'; + +const Homey = require('homey'); +const util = require('/lib/util.js'); + +class PowerPlugDevice extends Homey.Device { + + onInit() { + this.registerCapabilityListener('onoff', this.onCapabilityOnoff.bind(this)); + + var interval = this.getSetting('polling') || 60; + this.pollDevice(interval); + } + + onAdded() { + var interval = this.getSetting('polling') || 60; + this.pollDevice(interval); + } + + onDeleted() { + clearInterval(this.pollingInterval); + } + + // LISTENERS FOR UPDATING CAPABILITIES + onCapabilityOnoff(value, opts, callback) { + if(value == 'on') { + var power = 'turnon'; + } else { + var power = 'turnoff'; + } + util.sendCommand(power, 0, this.getSetting('address'), this.getSetting('token'), function(error, result) { + if (error) { + callback(error, false); + } else { + this.setCapabilityValue('onoff', value); + callback(null, value); + } + }); + } + + // HELPER FUNCTIONS + pollDevice(interval) { + clearInterval(this.pollingInterval); + + this.pollingInterval = setInterval(() => { + util.getPowerPlug(this.getSetting('address'), this.getSetting('token')) + .then(result => { + if (this.getCapabilityValue('onoff') != result.onoff) { + this.setCapabilityValue('onoff', result.onoff); + } + if (this.getCapabilityValue('measure_power') != result.load) { + this.setCapabilityValue('measure_power', result.load); + } + if (this.getCapabilityValue('meter_power') != result.consumed) { + this.setCapabilityValue('meter_power', result.consumed); + } + }) + .catch(error => { + this.log(error); + }) + }, 1000 * interval); + } + +} + +module.exports = PowerPlugDevice; diff --git a/drivers/mi-power-plug/driver.js b/drivers/mi-power-plug/driver.js new file mode 100644 index 0000000..db435ee --- /dev/null +++ b/drivers/mi-power-plug/driver.js @@ -0,0 +1,22 @@ +"use strict"; + +const Homey = require('homey'); +const util = require('/lib/util.js'); + +class PowerPlugDriver extends Homey.Driver { + + onPair(socket) { + socket.on('testConnection', function(data, callback) { + util.getPowerPlug(data.address, data.token) + .then(result => { + callback(null, result); + }) + .catch(error => { + callback(error, false); + }) + }); + } + +} + +module.exports = PowerPlugDriver; diff --git a/drivers/mi-power-plug/pair/start.html b/drivers/mi-power-plug/pair/start.html new file mode 100644 index 0000000..3d0cca6 --- /dev/null +++ b/drivers/mi-power-plug/pair/start.html @@ -0,0 +1,142 @@ + + + + +

Enter the details of your Mi Home device.

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+

Connection test successfull, you can now connect the device.

+

Mi Home device added succesfully.

+

+
diff --git a/drivers/philips-bulb/assets/icon.svg b/drivers/philips-bulb/assets/icon.svg new file mode 100644 index 0000000..b48b70c --- /dev/null +++ b/drivers/philips-bulb/assets/icon.svg @@ -0,0 +1,232 @@ + + + + +Created by potrace 1.10, written by Peter Selinger 2001-2011 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drivers/philips-bulb/assets/images/large.jpg b/drivers/philips-bulb/assets/images/large.jpg new file mode 100644 index 0000000000000000000000000000000000000000..63f5e129e0bae31b7c120868398f0b7a2c440eec GIT binary patch literal 9662 zcmeHtcUY6#viBPTL6Is&I$Yp@6s1WMLOC16tsr11DpgP*iF6H0ka|>#6gRr1!v;wp zKq4ZB7RpuxX^Id^Afbaa>7m07-g~xK_Id6f-=E(idEWJ|S&ag4-Vnfj z?#!=e01yZ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0Z9D$#!l8nQl(E=lz$%bjnC z9ybm#R?G;5^i)YaVrvk-ML-$MP5hID?Vv{@$Z3>f#;sNmx=Nx%Tbi9S%}Sik$bTm3r7mUo%5`kTjKpWP0(h|RyTrmD=rI^ zcx?sZh7x)+^CVzz8i;XmNbxQ&?>1F))upQ)si&C?zmxYjbueQVBs14_d`4X$Cxv98 z8|wN-Q1BRfrvE`E>YZ_deIrZE9*KTQ9-gY{1) p{(DI3ZND>%hCz0Rctf`#)FtfA9%A3`p$t{Wp94Tl4?` literal 0 HcmV?d00001 diff --git a/drivers/philips-bulb/assets/images/small.jpg b/drivers/philips-bulb/assets/images/small.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f9d51b3bee7432a4c0dff8e734d02462813b3dc8 GIT binary patch literal 776 zcmex=i3*BJ!6k`h{6D}T z$id*v;LXe^$iO7X$SlbC{|JK&10w?yGswAcz{tYP%Er#b0hBcnU|?is0`gh7q0%7L zEP|{;iiT`Tj>5`DffJn)3m>wJm<9zG6*q1=coC>e6va5OMvzrvf*9hAg8y$Z@Gt`n z6=W7Y7^*-g3?9qpJWGq=EWKsUP;rZ|OO;@BtSOl5^ z1O$>+d}w~}crNKnfv5G8ljS@3@)9rI%dq^RoH@hIM)g6}6uF6;n7}UOFbK18_xmaP zuqUnjKwfj-al<=oTy9CBQ+ZNE^$c7sbEXx~F59^)J}{{{_^|1WI_-|*{%w9YBTia& zoIQQ>=DUxj8#!z(8KEvL%-{6d-p&6}9fwW1#NKfJ3&CfsBW^~0x^ZHMLCCC literal 0 HcmV?d00001 diff --git a/drivers/philips-bulb/device.js b/drivers/philips-bulb/device.js new file mode 100644 index 0000000..00c521f --- /dev/null +++ b/drivers/philips-bulb/device.js @@ -0,0 +1,92 @@ +'use strict'; + +const Homey = require('homey'); +const util = require('/lib/util.js'); + +class PhilipsBulbDevice extends Homey.Device { + + onInit() { + this.registerCapabilityListener('onoff', this.onCapabilityOnoff.bind(this)); + this.registerCapabilityListener('dim', this.onCapabilityDim.bind(this)); + this.registerCapabilityListener('light_temperature', this.onCapabilityLightTemperature.bind(this)); + + var interval = this.getSetting('polling') || 60; + this.pollDevice(interval); + } + + onAdded() { + var interval = this.getSetting('polling') || 60; + this.pollDevice(interval); + } + + onDeleted() { + clearInterval(this.pollingInterval); + } + + // LISTENERS FOR UPDATING CAPABILITIES + onCapabilityOnoff(value, opts, callback) { + if(value == 'on') { + var power = 'turnon'; + } else { + var power = 'turnoff'; + } + util.sendCommand(power, 0, this.getSetting('address'), this.getSetting('token'), function(error, result) { + if (error) { + callback(error, false); + } else { + this.setCapabilityValue('onoff', value); + callback(null, value); + } + }); + } + + onCapabilityDim(value, opts, callback) { + var brightness = value * 100; + util.sendCommand('dim', brightness, this.getSetting('address'), this.getSetting('token'), function(error, result) { + if (error) { + callback(error, false); + } else { + this.setCapabilityValue('dim', value); + callback(null, value); + } + }); + } + + onCapabilityLightTemperature(value, opts, callback) { + util.sendCommand('colortemperature', value, this.getSetting('address'), this.getSetting('token'), function(error, result) { + if (error) { + callback(error, false); + } else { + this.setCapabilityValue('light_temperature', value); + callback(null, value); + } + }); + } + + // HELPER FUNCTIONS + pollDevice(interval) { + clearInterval(this.pollingInterval); + + this.pollingInterval = setInterval(() => { + util.getPhilipsBulb(this.getSetting('address'), this.getSetting('token')) + .then(result => { + var dim = result.brightness / 100; + if (this.getCapabilityValue('onoff') != result.onoff) { + this.setCapabilityValue('onoff', result.onoff); + } + if (this.getCapabilityValue('dim') != dim) { + this.setCapabilityValue('dim', dim); + } + if (this.getCapabilityValue('light_temperature') != result.colorTemperature) { + this.setCapabilityValue('light_temperature', result.colorTemperature); + } + }) + .catch(error => { + this.log(error); + }) + }, 1000 * interval); + } + +} + +module.exports = PhilipsBulbDevice; diff --git a/drivers/philips-bulb/driver.js b/drivers/philips-bulb/driver.js new file mode 100644 index 0000000..a88fb16 --- /dev/null +++ b/drivers/philips-bulb/driver.js @@ -0,0 +1,22 @@ +"use strict"; + +const Homey = require('homey'); +const util = require('/lib/util.js'); + +class PhilipsBulbDriver extends Homey.Driver { + + onPair(socket) { + socket.on('testConnection', function(data, callback) { + util.getPhilipsBulb(data.address, data.token) + .then(result => { + callback(null, result); + }) + .catch(error => { + callback(error, false); + }) + }); + } + +} + +module.exports = PhilipsBulbDriver; diff --git a/drivers/philips-bulb/pair/start.html b/drivers/philips-bulb/pair/start.html new file mode 100644 index 0000000..08df25c --- /dev/null +++ b/drivers/philips-bulb/pair/start.html @@ -0,0 +1,142 @@ + + + + +

Enter the details of your Mi Home device.

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+

Connection test successfull, you can now connect the device.

+

Mi Home device added succesfully.

+

+
diff --git a/drivers/philips-eyecare/assets/icon.svg b/drivers/philips-eyecare/assets/icon.svg new file mode 100644 index 0000000..91bb766 --- /dev/null +++ b/drivers/philips-eyecare/assets/icon.svg @@ -0,0 +1,100 @@ + + + + +Created by potrace 1.10, written by Peter Selinger 2001-2011 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drivers/philips-eyecare/assets/images/large.jpg b/drivers/philips-eyecare/assets/images/large.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8a5a6eb29b11b87ba4a81a06e412165f337bd1c0 GIT binary patch literal 7629 zcmcIp2UJtpx;~)q2DGA(BK?DLKND)v#dVo*_5<)1~LQ$fOQWTN_ z1*9WgsaFu96ags$6RNa;A)$qS!^|yf-g@t?@YZ_&Sy}t+v-kP;_xWya!mc_iO*+-`s3>Ol}mN{A9fgZ3HbE>Js`MYo`?2)!DV~8YOAop91-5& zBDgJI)y1%nAkk_reCk9p67Nq=+?263wN5%mxBp02@mlYzK$Z7*uQtc{vrk3%>`qqA z&jsUpiKv(>SZ8ueuz0uYXUEtCOR?}LVmlr=YBHx*!=j`*8`GzFNByxf3-rRii3Z3A zF@)T(X|i7)%n!5W_GE)|WaVXuWxPj1I^@h;q_5gYW>Z8$#Zb7vV8#h+f$n;pmZ(s6 zQ3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?kvDP_lU=X>NM%$4jP+-T-gxYu|(LxK+xu)v!k)^PLU zW|Y@9Co*D7(7j7U0Lw7EKU&{2NnB_=YflK5*ufZMLB3e&C4RhI_E_wKJDE0H!8K4y zRKRCmKbk){oYcMjIHS>Za*79(W1S>34t6_dxRikV@j@E!21-th^zfui6kwvBm>th9 zwlcuHGqLD%hzd~dfs?G-Bh9`X8vG~le>EciIza)CBDnzGLBYsD!6@l37wYv5m4#eE z?U5Gn{Y#7d+i3*BJ!6k`h{6D}T z$id*v;LXe^$iO7X$SlbC{|JK&10w??DK{g>_Lq~QIMH8pO%}UCF!HLC<%@ZdrJopf(NfhLHQ~=}M7VUR0MyLMOeWX-GZd&O=^d*z$GR$ApbuVdzo!%^K^Cst z-{R@F@Sn_SU0pN%pf*V`sm88rT5A}{9sf1t?ca*VMQgUi>+TMYd={ygmA-1#s@)%M zozf70xi{u?&)%SwyH~AeS1GetK0{UmYJiN}vaPzN=ht5P&0oJSX}PBGUxhasS+hgk zS-mTKj_sGr2%G~^$+qdc-=uA-&t@_%`>iWz{B)OF-A$Q>oC6S9m-Tsp^AZv_sOkP^ zm~Fn|ftdnCT=`l-g5aCjqjg{IEpE605o0(Q`jE+V@=pDGv#%6LL&YSrY82cym8<@~ zT-C=^0TMhRw##jMhg{_)v8`9ctaijZCa>EQEqA_Nb?=#bhn4hMTTgU7TUGW{girFW zZJ@JS`u6)T=blp!H2z&6=6ZQ9%cZ2-%f7PaypMUaN%xl4s=uN)n6GY;eI9t{t#)L^ zmb00Y!q+|OTI4b { + util.getPhilipsEyecare(this.getSetting('address'), this.getSetting('token')) + .then(result => { + var dim = result.brightness / 100; + if (this.getCapabilityValue('onoff') != result.onoff) { + this.setCapabilityValue('onoff', result.onoff); + } + if (this.getCapabilityValue('dim') != dim) { + this.setCapabilityValue('dim', dim); + } + if (this.getStoreValue('mode') != result.mode) { + this.setStoreValue('mode', result.mode); + } + }) + .catch(error => { + this.log(error); + }) + }, 1000 * interval); + } + +} + +module.exports = PhilipsEyecareDevice; diff --git a/drivers/philips-eyecare/driver.js b/drivers/philips-eyecare/driver.js new file mode 100644 index 0000000..2baede7 --- /dev/null +++ b/drivers/philips-eyecare/driver.js @@ -0,0 +1,22 @@ +"use strict"; + +const Homey = require('homey'); +const util = require('/lib/util.js'); + +class PhilipsEyecareDriver extends Homey.Driver { + + onPair(socket) { + socket.on('testConnection', function(data, callback) { + util.getPhilipsEyecare(data.address, data.token) + .then(result => { + callback(null, result); + }) + .catch(error => { + callback(error, false); + }) + }); + } + +} + +module.exports = PhilipsEyecareDriver; diff --git a/drivers/philips-eyecare/pair/start.html b/drivers/philips-eyecare/pair/start.html new file mode 100644 index 0000000..31e3255 --- /dev/null +++ b/drivers/philips-eyecare/pair/start.html @@ -0,0 +1,146 @@ + + + + +

Enter the details of your Mi Home device.

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+

Connection test successfull, you can now connect the device.

+

Mi Home device added succesfully.

+

+
diff --git a/drivers/yeelights/assets/bslamp.svg b/drivers/yeelights/assets/bslamp.svg index 5d62acd..6b0b634 100644 --- a/drivers/yeelights/assets/bslamp.svg +++ b/drivers/yeelights/assets/bslamp.svg @@ -1,49 +1,19 @@ - - - - -Created by potrace 1.10, written by Peter Selinger 2001-2011 - - - - - - - - + + + + + + + diff --git a/drivers/yeelights/assets/ceiling.svg b/drivers/yeelights/assets/ceiling.svg index 4f8a5ba..c9660e6 100644 --- a/drivers/yeelights/assets/ceiling.svg +++ b/drivers/yeelights/assets/ceiling.svg @@ -1,32 +1,22 @@ - - - - -Created by potrace 1.10, written by Peter Selinger 2001-2011 - - - - - + + + + + diff --git a/drivers/yeelights/assets/ceiling4.svg b/drivers/yeelights/assets/ceiling4.svg new file mode 100644 index 0000000..4f8a5ba --- /dev/null +++ b/drivers/yeelights/assets/ceiling4.svg @@ -0,0 +1,32 @@ + + + + +Created by potrace 1.10, written by Peter Selinger 2001-2011 + + + + + + diff --git a/drivers/yeelights/driver.js b/drivers/yeelights/driver.js index 4e867d2..5116c72 100644 --- a/drivers/yeelights/driver.js +++ b/drivers/yeelights/driver.js @@ -4,19 +4,21 @@ const Homey = require('homey'); const yeelight = require('/lib/yeelight.js'); const typeCapabilityMap = { - 'mono' : [ 'onoff', 'dim' ], - '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' ], - 'ceiling' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode' ], + 'mono' : [ 'onoff', 'dim' ], + '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' ], + 'ceiling' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode' ], + 'ceiling4' : [ 'onoff', 'dim', 'light_hue', 'light_saturation', 'light_temperature', 'light_mode' ], } const typeIconMap = { - 'mono' : 'bulb.svg', - 'color' : 'bulb.svg', - 'stripe' : 'strip.svg', - 'bslamp' : 'bslamp.svg', - 'ceiling': 'ceiling.svg' + 'mono' : 'bulb.svg', + 'color' : 'bulb.svg', + 'stripe' : 'strip.svg', + 'bslamp' : 'bslamp.svg', + 'ceiling' : 'ceiling.svg', + 'ceiling4': 'ceiling4.svg' } class YeelightDriver extends Homey.Driver { @@ -38,7 +40,7 @@ class YeelightDriver extends Homey.Driver { var name = Homey.__('yeelight_led_strip')+ ' (' + result[i].address + ')'; } else if (result[i].model == 'bslamp') { var name = Homey.__('yeelight_bedside_lamp')+ ' (' + result[i].address + ')'; - } else if (result[i].model == 'ceiling') { + } else if (result[i].model == 'ceiling' || result[i].model == 'ceiling4') { var name = Homey.__('yeelight_ceiling_light')+ ' (' + result[i].address + ')'; } devices.push({ diff --git a/lib/util.js b/lib/util.js index d629bb8..99d0ea7 100644 --- a/lib/util.js +++ b/lib/util.js @@ -54,6 +54,78 @@ exports.getHumidifier = function (address, token) { }) } +exports.getPhilipsBulb = function (address, token) { + return new Promise(function (resolve, reject) { + miio.device({ + address: address, + token: token + }).then(device => { + + var onoff = device.power; + var brightness = device.brightness; + var colorTemperature = device.colorTemperature; + + result = { + onoff: onoff, + brightness: brightness, + colorTemperature: colorTemperature + } + + return resolve(result); + }).catch(function (error) { + return reject(error); + }); + }) +} + +exports.getPhilipsEyecare = function (address, token) { + return new Promise(function (resolve, reject) { + miio.device({ + address: address, + token: token + }).then(device => { + + var onoff = device.power; + var brightness = device.brightness; + var mode = device.eyeCareMode; + + result = { + onoff: onoff, + brightness: brightness, + mode: mode + } + + return resolve(result); + }).catch(function (error) { + return reject(error); + }); + }) +} + +exports.getPowerPlug = function (address, token) { + return new Promise(function (resolve, reject) { + miio.device({ + address: address, + token: token + }).then(device => { + + var onoff = device.power(0); + var load = device.loadPower; + var consumed = device.powerConsumed; + + result = { + onoff: onoff, + load: load, + consumed: consumed + } + + return resolve(result); + }).catch(function (error) { + return reject(error); + }); + }) +} + exports.sendCommand = function (command, value, address, token) { return new Promise(function (resolve, reject) { miio.device({ @@ -131,12 +203,43 @@ exports.sendCommand = function (command, value, address, token) { .then(result => { return resolve(true) }) .then(error => { return reject(error) }); break; + case 'study': + device.setEyecareMode('study') + .then(result => { return resolve(true) }) + .then(error => { return reject(error) }); + break; + case 'reading': + device.setEyecareMode('reading') + .then(result => { return resolve(true) }) + .then(error => { return reject(error) }); + break; + case 'phone': + device.setEyecareMode('phone') + .then(result => { return resolve(true) }) + .then(error => { return reject(error) }); + break; default: device.setMode('auto') .then(result => { return resolve(true) }) .then(error => { return reject(error) }); } break; + /* LIGHTS */ + case 'dim': + device.setBrightness(value) + .then(result => { return resolve(true) }) + .then(error => { return reject(error) }); + break; + case 'colortemperature': + device.colorTemperature(value) + .then(result => { return resolve(true) }) + .then(error => { return reject(error) }); + break; + case 'eyecare': + device.setEyeCare(value) + .then(result => { return resolve(true) }) + .then(error => { return reject(error) }); + break; default: this.log("Not a valid command"); return reject("Not a valid command"); diff --git a/locales/en.json b/locales/en.json index 7f5acbc..02b6d9d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -5,9 +5,16 @@ "intro": "Enter the details of your Mi Home device.", "airpurifier": "Airpurifier", "humidifier": "Humidifier", + "philipsbulb": "Philips Light Bulb", + "philipseyecare": "Philips Eyecare Lamp", + "powerplug": "Mi Power Plug", "powered": "Powered:", "mode": "Mode:", + "dim": "Dim Level:", "temperature": "Temperature:", + "colortemperature": "Color Temperature:", + "load": "Current Load In Watt:", + "consumed": "Consumed Power in kWh:", "humidity": "Humidity:", "aqi": "Air Quality Index:", "address": "IP Address", diff --git a/locales/nl.json b/locales/nl.json index f909bb6..b947096 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -5,9 +5,16 @@ "intro": "Vul de details van je Mi Home apparaat in.", "airpurifier": "Luchtreiniger", "humidifier": "Luchtbevochtiger", + "philipsbulb": "Philips Light Bulb", + "philipseyecare": "Philips Eyecare Lamp", + "powerplug": "Mi Power Plug", "powered": "Aangezet:", "mode": "Modus:", + "dim": "Dim niveau:", "temperature": "Temperatuur:", + "colortemperature": "Kleurtemperatuur:", + "load": "Huidige gebruik in Watt:", + "consumed": "Verbruikte stroom in kWh:", "humidity": "Luchtvochtigheid:", "aqi": "Air Quality Index:", "address": "IP adres", diff --git a/package.json b/package.json index b9e439e..291d8a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.xiaomi-miio", - "version": "2.3.2", + "version": "2.4.0", "description": "Xiaomi Mi Home", "main": "app.js", "dependencies": {