Add support for ATC_MiThermometer, update bindkey generation procedure (#777)

* add ATC MiThermometer component

* correct unordered list

* update text and fix formatting errors

* ident warning four spaces

* add Telink flasher screenshot

* add battery voltage to ATC MiThermometer

* edit ATC Mithermometer config
This commit is contained in:
Alexander Pohl 2020-11-03 18:36:20 +01:00 committed by GitHub
parent d608db993c
commit 3b0540d5e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View File

@ -156,13 +156,21 @@ Configuration example:
LYWSD03MMC
**********
Hygro thermometer, small square body, segment LCD, encrypted, broadcasts temperature, humidity and battery status. Requires a bindkey in order to decrypt the received data (see :ref:`obtaining_the_bindkey`).
Hygro thermometer, small square body, segment LCD, encrypted, broadcasts temperature, humidity and battery status.
.. figure:: images/xiaomi_lywsd03mmc.jpg
:align: center
:width: 30.0%
Configuration example:
There are the following possibilities to operate this sensor:
1. Xiaomi stock firmware (requires a bindkey in order to decrypt the received data, see :ref:`obtaining_the_bindkey`)
2. Device flashed with `ATC MiThermometer <https://github.com/atc1441/ATC_MiThermometer>`__ custom firmware
- "Mi Like" advertisement (dummy bindkey required)
- "Custom" advertisement (no bindkey required)
Configuration example for Xiaomi stock firmware or ATC MiThermometer firmware set to "Mi Like" advertisement:
.. code-block:: yaml
@ -176,6 +184,22 @@ Configuration example:
name: "LYWSD03MMC Humidity"
battery_level:
name: "LYWSD03MMC Battery Level"
Configuration example for ATC MiThermometer firmware set to "Custom" advertisement:
.. code-block:: yaml
sensor:
- platform: atc_mithermometer
mac_address: "A4:C1:38:B1:CD:7F"
temperature:
name: "ATC Temperature"
humidity:
name: "ATC Humidity"
battery_level:
name: "ATC Battery-Level"
battery_voltage:
name: "ATC Battery-Voltage"
CGD1
****
@ -339,9 +363,29 @@ It can sometimes take some time for the first BLE broadcast to be received. Once
Obtaining The Bindkey
---------------------
To set up an encrypted device such as the LYWSD03MMC or CGD1, you first need to obain the bind key. The ``xiaomi_ble`` sensor component is not able to automatically generate a bind key, so you need to use the original Mi Home app to add the sensor once (there are `efforts <https://github.com/danielkucera/mi-standardauth>`__ to generate a bindkey without the need for packet sniffing, but it's not working correctly yet). While adding the device, a new key is generated and uploaded into the Xiaomi cloud and to the device itself. Currently a chinese server needs to be selected as the rest of the world doesn't support most of these devices yet. Once generated, the key will not change again until the device is removed and re-added in the Xiaomi app.
To set up an encrypted device such as the LYWSD03MMC (with Xiaomi stock firmware) and CGD1, you first need to obain the bind key. The ``xiaomi_ble`` sensor component is not able to automatically generate a bind key so other workarounds are necessary.
In order to obtain the bind key, a SSL packet sniffer needs to be setup on either an Android phone or the iPhone. A good choice for Android is the `Remote PCAP <https://play.google.com/store/apps/details?id=com.egorovandreyrm.pcapremote&hl=en>`__ in combination with `Wireshark <https://www.wireshark.org/>`__. A tutorial on how to setup the Remote PCAP packet sniffer can be found `here <https://egorovandreyrm.com/pcap-remote-tutorial/>`__. Instructions how to obtain the key using an iPhone are `here <https://github.com/custom-components/sensor.mitemp_bt/blob/master/faq.md#my-sensors-ble-advertisements-are-encrypted-how-can-i-get-the-key>`__. Once the traffic between the Mi Home app and the Xiaomi has been recorded, the bind key will show in clear text:
LYWSD03MMC
**********
If the LYWSD03MMC sensor is operated with the Xiaomi stock firmware, you can use the `TeLink flasher application <https://atc1441.github.io/TelinkFlasher.html>`__ to easily generate a new bind key and upload the key to the device without the need to flash a new firmware (see figure). For this, you load the flasher `webpage <https://atc1441.github.io/TelinkFlasher.html>`__ with a `supported browser <https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md>`__ and connect the device by pressing "Connect". After the connection is established, you press the "Do Activation" button and the new key will be shown in the "Mi Bind Key" field. The key can be copied directly into the sensor YAML configuration.
.. figure:: images/telink_flasher.jpg
:align: center
:width: 100.0%
Telink flasher application.
.. warning::
The new bind key will work with ESPHome, but the Mi Home app will not recognise the sensor anymore once the device has been activated by the TeLink flasher application. To use the sensor again with the Xiaomi Mi Home app, the device needs to be removed and then re-added inside the Mi Home app.
Other encrypted devices
***********************
For other encrypted devices such as the CGD1, you still need to use the original Mi Home app to add the sensor once. While adding the device, a new key is generated and uploaded into the Xiaomi cloud and to the device itself. Currently a chinese server needs to be selected as the rest of the world doesn't support most of these devices yet. Once generated, the key will not change again until the device is removed and re-added in the Xiaomi app.
In order to obtain the bind key, a SSL packet sniffer needs to be setup on either an Android phone or the iPhone. A good choice for Android is the `Remote PCAP <https://play.google.com/store/apps/details?id=com.egorovandreyrm.pcapremote&hl=en>`__ in combination with `Wireshark <https://www.wireshark.org/>`__. A tutorial on how to setup the Remote PCAP packet sniffer can be found `here <https://egorovandreyrm.com/pcap-remote-tutorial/>`__ and `here <https://github.com/ahpohl/xiaomi_lywsd03mmc>`__. Instructions how to obtain the key using an iPhone are `here <https://github.com/custom-components/sensor.mitemp_bt/blob/master/faq.md#my-sensors-ble-advertisements-are-encrypted-how-can-i-get-the-key>`__. Once the traffic between the Mi Home app and the Xiaomi servers has been recorded, the bind key will show in clear text:
.. code-block:: yaml
@ -361,6 +405,7 @@ See Also
- Xiaomi Home Assistant mitemp_bt custom component `<https://github.com/custom-components/sensor.mitemp_bt>`__
by `@Magalex2x14 <https://github.com/Magalex2x14>`__
- Xiaomi LYWSD03MMC passive sensor readout `<https://github.com/ahpohl/xiaomi_lywsd03mmc>`__ by `@ahpohl <https://github.com/ahpohl>`__
- Mi-standardauth `<https://github.com/danielkucera/mi-standardauth>`__
- Custom firmware for the Xiaomi Thermometer LYWSD03MMC `<https://github.com/atc1441/ATC_MiThermometer>`__
- TeLink flasher application `<https://atc1441.github.io/TelinkFlasher.html>`__
- :ghedit:`Edit`