From 946779c9841817259482aabee01ab1b3ab1f4423 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 26 Aug 2017 09:15:41 +0200 Subject: [PATCH 1/5] Documentation for Xiaomi Philips Light component added. --- .../light.xiaomi_philipslight.markdown | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 source/_components/light.xiaomi_philipslight.markdown diff --git a/source/_components/light.xiaomi_philipslight.markdown b/source/_components/light.xiaomi_philipslight.markdown new file mode 100644 index 000000000000..7e8d6cff7ca6 --- /dev/null +++ b/source/_components/light.xiaomi_philipslight.markdown @@ -0,0 +1,105 @@ +--- +layout: page +title: "Xiaomi Philips Light" +description: "Instructions how to integrate your Xiaomi Philips Lights within Home Assistant." +date: 2017-08-26 08:45 +sidebar: true +comments: false +sharing: true +footer: true +logo: philips.png +ha_category: Light +ha_iot_class: "Local Polling" +--- + +The `xiaomi_philipslight` platform allows you to control the state of your [Xiaomi Philips LED Ball Lamp and Xiaomi Philips LED Ceiling Lamp. + +Current supported features are `on`, `off`, `set_cct` (colortemp) , `set_bright` (brightness). + +## {% linkable_title Getting started %} + +Follow the pairing process using your phone and Mi-Home app. From here you will be able to retrieve the token from a SQLite file inside your phone. + +Before you begin you need to install `libffi-dev` by running the command below. This is needed for `python-mirobi` to be installed correctly. + +```bash +apt-get install libffi-dev +``` + +

+If your Home Assistant installation is running in a [Virtualenv](/docs/installation/virtualenv/#upgrading-home-assistant), make sure you activate it by running the commands below.

+ +```bash +$ sudo su -s /bin/bash homeassistant +$ source /srv/homeassistant/bin/activate +``` + +To fetch the token follow these instructions depending on your mobile phone platform. + +### Windows and Android +1. Configure the light with the Mi-Home app. +2. Enable developer mode and USB debugging on the Android phone and plug it into the computer. +3. Get ADB tool for Windows: https://developer.android.com/studio/releases/platform-tools.html +4. Create a backup of the application com.xiaomi.smarthome: +```bash +.\adb backup -noapk com.xiaomi.smarthome -f backup.ab +``` +5. If you have this message: "More than one device or emulator", use this command to list all devices: +```bash +.\adb devices +``` +and execute this command: +```bash +.\adb -s DEVICEID backup -noapk com.xiaomi.smarthome -f backup.ab # (with DEVICEID the device id from the previous command) +``` +6. On the phone, you must confirm the backup. DO NOT enter any password and press button to make the backup. +7. Get ADB Backup Extractor: https://sourceforge.net/projects/adbextractor/ +8. Extract All files from the backup: +```bash +java.exe -jar ../android-backup-extractor/abe.jar unpack backup.ab backup.tar "" +``` +9. Unzip the ".tar" file. +10. Open the SQLite DB miio2.db with a tool like SQLite Manager extension for FireFox. +11. Get the token from "devicerecord" table. The token you need is in the column **`token`** and looks like **`123a1234567b12345c1d123456789e12`**. + +### Linux and Android (rooted!) + +1. Configure the light with the Mi-Home app. +2. Enable developer mode, USB debugging and root permission only for ADB on the Android phone and plug it into the computer. +3. Get ADB f.e. `apt-get install android-tools-adb` +4. `adb devices` should list your device +5. `adb root` (does work for development builds only: ones with ro.debuggable=1) +6. `adb shell` +7. `echo "select name,localIP,token from devicerecord;" | sqlite3 /data/data/com.xiaomi.smarthome/databases/miio2.db` returns a list of all registered devices including ip address and token. + +```bash +$ echo "select name,localIP,token from devicerecord;" | sqlite3 /data/data/com.xiaomi.smarthome/databases/miio2.db +Philips connected bulb|192.168.130.67|your-led-ball-token-here +``` + +### macOS and iOS +1. Setup iOS device with the Mi-Home app. +2. Create an unencrypted backup of the device using iTunes. +3. Install iBackup Viewer from here: http://www.imactools.com/iphonebackupviewer/ +4. Extract this file: **`/raw data/com.xiami.mihome/1234567_mihome.sqlite`** to your computer, where _1234567_ is any string of numbers. +5. Open the sqlite DB with a tool like SQLite Manager extension for FireFox, DB Browser, etc. You will then see the list of all the devices in your account with their token. The token you need is in the column **`ZToken`** and looks like **`123a1234567b12345c1d123456789e12`**. + +## {% linkable_title Configuration %} + +```yaml +# Example configuration.yaml entries +light: + - platform: xiaomi_philipslight + name: Xiaomi Philips Smart LED Ball + host: 192.168.130.67 + token: your-led-ball-token-here + - platform: xiaomi_philipslight + name: Xiaomi Philips Smart LED Ceiling Lamp + host: 192.168.130.68 + token: your-ceiling-lamp-token-here +``` + +Configuration variables: +- **name** (*Optional*): The name of your light +- **host** (*Required*): The IP of your light +- **token** (*Required*): The token of your light. Go to Getting started section to read more about how to get it. From 7475132e8120af3315e69aa00d94f9bb8f930504 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 26 Aug 2017 09:36:34 +0200 Subject: [PATCH 2/5] HA version added. --- source/_components/light.xiaomi_philipslight.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/source/_components/light.xiaomi_philipslight.markdown b/source/_components/light.xiaomi_philipslight.markdown index 7e8d6cff7ca6..a895e350f202 100644 --- a/source/_components/light.xiaomi_philipslight.markdown +++ b/source/_components/light.xiaomi_philipslight.markdown @@ -9,6 +9,7 @@ sharing: true footer: true logo: philips.png ha_category: Light +ha_version: 0.53 ha_iot_class: "Local Polling" --- From 2302f001e7476760e928dff60346fb46e53bf980 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 26 Aug 2017 10:24:37 +0200 Subject: [PATCH 3/5] Syntax error fixed. --- source/_components/light.xiaomi_philipslight.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/light.xiaomi_philipslight.markdown b/source/_components/light.xiaomi_philipslight.markdown index a895e350f202..5c6e5be837e9 100644 --- a/source/_components/light.xiaomi_philipslight.markdown +++ b/source/_components/light.xiaomi_philipslight.markdown @@ -13,7 +13,7 @@ ha_version: 0.53 ha_iot_class: "Local Polling" --- -The `xiaomi_philipslight` platform allows you to control the state of your [Xiaomi Philips LED Ball Lamp and Xiaomi Philips LED Ceiling Lamp. +The `xiaomi_philipslight` platform allows you to control the state of your Xiaomi Philips LED Ball Lamp and Xiaomi Philips LED Ceiling Lamp. Current supported features are `on`, `off`, `set_cct` (colortemp) , `set_bright` (brightness). From 258d0e6b7a3939720053b73dc1924f7c60f018ae Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 26 Aug 2017 14:44:56 +0200 Subject: [PATCH 4/5] Section "Retrieving the Access Token" has a central place now. --- .../light.xiaomi_philipslight.markdown | 82 ++----------------- 1 file changed, 6 insertions(+), 76 deletions(-) diff --git a/source/_components/light.xiaomi_philipslight.markdown b/source/_components/light.xiaomi_philipslight.markdown index 5c6e5be837e9..752a5fc47ea5 100644 --- a/source/_components/light.xiaomi_philipslight.markdown +++ b/source/_components/light.xiaomi_philipslight.markdown @@ -17,75 +17,9 @@ The `xiaomi_philipslight` platform allows you to control the state of your Xiaom Current supported features are `on`, `off`, `set_cct` (colortemp) , `set_bright` (brightness). -## {% linkable_title Getting started %} +Please follow the instructions on [Retrieving the Access Token](/xiaomi/#retrieving-the-access-token) to get the API token to use in the `configuration.yaml` file. -Follow the pairing process using your phone and Mi-Home app. From here you will be able to retrieve the token from a SQLite file inside your phone. - -Before you begin you need to install `libffi-dev` by running the command below. This is needed for `python-mirobi` to be installed correctly. - -```bash -apt-get install libffi-dev -``` - -

-If your Home Assistant installation is running in a [Virtualenv](/docs/installation/virtualenv/#upgrading-home-assistant), make sure you activate it by running the commands below.

- -```bash -$ sudo su -s /bin/bash homeassistant -$ source /srv/homeassistant/bin/activate -``` - -To fetch the token follow these instructions depending on your mobile phone platform. - -### Windows and Android -1. Configure the light with the Mi-Home app. -2. Enable developer mode and USB debugging on the Android phone and plug it into the computer. -3. Get ADB tool for Windows: https://developer.android.com/studio/releases/platform-tools.html -4. Create a backup of the application com.xiaomi.smarthome: -```bash -.\adb backup -noapk com.xiaomi.smarthome -f backup.ab -``` -5. If you have this message: "More than one device or emulator", use this command to list all devices: -```bash -.\adb devices -``` -and execute this command: -```bash -.\adb -s DEVICEID backup -noapk com.xiaomi.smarthome -f backup.ab # (with DEVICEID the device id from the previous command) -``` -6. On the phone, you must confirm the backup. DO NOT enter any password and press button to make the backup. -7. Get ADB Backup Extractor: https://sourceforge.net/projects/adbextractor/ -8. Extract All files from the backup: -```bash -java.exe -jar ../android-backup-extractor/abe.jar unpack backup.ab backup.tar "" -``` -9. Unzip the ".tar" file. -10. Open the SQLite DB miio2.db with a tool like SQLite Manager extension for FireFox. -11. Get the token from "devicerecord" table. The token you need is in the column **`token`** and looks like **`123a1234567b12345c1d123456789e12`**. - -### Linux and Android (rooted!) - -1. Configure the light with the Mi-Home app. -2. Enable developer mode, USB debugging and root permission only for ADB on the Android phone and plug it into the computer. -3. Get ADB f.e. `apt-get install android-tools-adb` -4. `adb devices` should list your device -5. `adb root` (does work for development builds only: ones with ro.debuggable=1) -6. `adb shell` -7. `echo "select name,localIP,token from devicerecord;" | sqlite3 /data/data/com.xiaomi.smarthome/databases/miio2.db` returns a list of all registered devices including ip address and token. - -```bash -$ echo "select name,localIP,token from devicerecord;" | sqlite3 /data/data/com.xiaomi.smarthome/databases/miio2.db -Philips connected bulb|192.168.130.67|your-led-ball-token-here -``` - -### macOS and iOS -1. Setup iOS device with the Mi-Home app. -2. Create an unencrypted backup of the device using iTunes. -3. Install iBackup Viewer from here: http://www.imactools.com/iphonebackupviewer/ -4. Extract this file: **`/raw data/com.xiami.mihome/1234567_mihome.sqlite`** to your computer, where _1234567_ is any string of numbers. -5. Open the sqlite DB with a tool like SQLite Manager extension for FireFox, DB Browser, etc. You will then see the list of all the devices in your account with their token. The token you need is in the column **`ZToken`** and looks like **`123a1234567b12345c1d123456789e12`**. - -## {% linkable_title Configuration %} +To add a Xiaomi Philips Light to your installation, add the following to your configuration.yaml file: ```yaml # Example configuration.yaml entries @@ -93,14 +27,10 @@ light: - platform: xiaomi_philipslight name: Xiaomi Philips Smart LED Ball host: 192.168.130.67 - token: your-led-ball-token-here - - platform: xiaomi_philipslight - name: Xiaomi Philips Smart LED Ceiling Lamp - host: 192.168.130.68 - token: your-ceiling-lamp-token-here + token: YOUR_TOKEN ``` Configuration variables: -- **name** (*Optional*): The name of your light -- **host** (*Required*): The IP of your light -- **token** (*Required*): The token of your light. Go to Getting started section to read more about how to get it. +- **host** (*Required*): The IP of your light. +- **token** (*Required*): The API token of your light. +- **name** (*Optional*): The name of your light. From 8a4ac93492eff4d8bc1470ba9b81530c20fbce58 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 26 Aug 2017 18:22:43 +0200 Subject: [PATCH 5/5] Spelling & grammar fixed. --- source/_components/light.xiaomi_philipslight.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/light.xiaomi_philipslight.markdown b/source/_components/light.xiaomi_philipslight.markdown index 752a5fc47ea5..ec4d351e25f2 100644 --- a/source/_components/light.xiaomi_philipslight.markdown +++ b/source/_components/light.xiaomi_philipslight.markdown @@ -15,7 +15,7 @@ ha_iot_class: "Local Polling" The `xiaomi_philipslight` platform allows you to control the state of your Xiaomi Philips LED Ball Lamp and Xiaomi Philips LED Ceiling Lamp. -Current supported features are `on`, `off`, `set_cct` (colortemp) , `set_bright` (brightness). +Currently, the supported features are `on`, `off`, `set_cct` (colortemp) , `set_bright` (brightness). Please follow the instructions on [Retrieving the Access Token](/xiaomi/#retrieving-the-access-token) to get the API token to use in the `configuration.yaml` file.