esphome-docs/components/sensor/xiaomi_lywsdcgq.rst

102 lines
3.8 KiB
ReStructuredText
Raw Normal View History

Xiaomi LYWSDCGQ BLE Sensor
==========================
2018-11-14 22:12:27 +01:00
.. seo::
:description: Instructions for setting up Xiaomi Mi Jia LYWSDCGQ bluetooth-based temperature and humidity sensors in ESPHome.
:image: xiaomi_lywsdcgq.jpg
:keywords: Xiaomi, Mi Jia, BLE, Bluetooth, LYWSDCGQ
2018-11-14 22:12:27 +01:00
The ``xiaomi_lywsdcgq`` sensor platform lets you track the output of Xiaomi LYWSDCGQ Bluetooth Low Energy
devices using the :doc:`/components/esp32_ble_tracker`. This component will track the
temperature, humidity and optionally the battery level of the device every time the sensor
2019-02-16 23:25:23 +01:00
sends out a BLE broadcast. Note that contrary to other implementations, ESPHome can track as many
LYWSDCGQ devices at once as you want.
.. figure:: images/xiaomi_lywsdcgq-full.jpg
:align: center
:width: 60.0%
Xiaomi Temperature and Humidity Sensor over BLE.
.. figure:: images/xiaomi_lywsdcgq-ui.png
:align: center
:width: 80.0%
.. code-block:: yaml
# Example configuration entry
esp32_ble_tracker:
sensor:
- platform: xiaomi_lywsdcgq
mac_address: 7A:80:8E:19:36:BA
temperature:
name: "Xiaomi LYWSDCGQ Temperature"
humidity:
name: "Xiaomi LYWSDCGQ Humidity"
battery_level:
name: "Xiaomi LYWSDCGQ Battery Level"
Configuration variables:
2018-08-24 22:44:01 +02:00
------------------------
- **mac_address** (**Required**, MAC Address): The MAC address of the Xiaomi LYWSDCGQ device.
2018-10-17 20:50:15 +02:00
- **temperature** (*Optional*): The information for the temperature sensor.
- **name** (**Required**, string): The name for the temperature sensor.
- **id** (*Optional*, :ref:`config-id`): Set the ID of this sensor for use in lambdas.
2019-02-17 12:28:17 +01:00
- All other options from :ref:`Sensor <config-sensor>`.
2018-10-17 20:50:15 +02:00
- **humidity** (*Optional*): The information for the humidity sensor
- **name** (**Required**, string): The name for the humidity sensor.
- **id** (*Optional*, :ref:`config-id`): Set the ID of this sensor for use in lambdas.
2019-02-17 12:28:17 +01:00
- All other options from :ref:`Sensor <config-sensor>`.
- **battery_level** (*Optional*): The information for the battery level sensor
2019-10-30 16:03:39 +01:00
- **name** (**Required**, string): The name for the battery level sensor.
- **id** (*Optional*, :ref:`config-id`): Set the ID of this sensor for use in lambdas.
2019-02-17 12:28:17 +01:00
- All other options from :ref:`Sensor <config-sensor>`.
Setting Up Devices
2018-08-24 22:44:01 +02:00
------------------
To set up Xiaomi LYWSDCGQ devices you first need to find their MAC Address so that ESPHome can
identify them. So first, create a simple configuration without any ``xiaomi_lywsdcgq`` entries like so:
.. code-block:: yaml
esp32_ble_tracker:
After uploading the ESP32 will immediately try to scan for BLE devices such as the Xiaomi LYWSDCGQ. When
it detects these sensors, it will automatically parse the BLE message print a message like this one:
.. code::
Got Xiaomi LYWSDCGQ 7A:80:8E:19:36:BA Got temperature=23.4°C, humidity=65.0%
Note that it can sometimes take some time for the first BLE broadcast to be received. You can speed up
the process by pressing the grey bluetooth button on the back of the device.
Then just copy the address (``7A:80:8E:19:36:BA``) into a new ``sensor.xiaomi_lywsdcgq`` platform entry like
in the configuration example at the top.
2019-06-04 13:12:16 +02:00
.. note::
The ESPHome Xiaomi integration listens passively to packets the xiaomi device sends by itself.
ESPHome therefore has no impact on the battery life of the device.
See Also
2018-08-24 22:44:01 +02:00
--------
- :doc:`/components/esp32_ble_tracker`
- :doc:`/components/sensor/xiaomi_hhccjcy01`
- :doc:`/components/sensor/index`
- :apiref:`xiaomi_lywsdcgq/xiaomi_lywsdcgq.h`
2019-02-27 18:32:47 +01:00
- `Xiaomi Mijia BLE protocol <https://github.com/mspider65/Xiaomi-Mijia-Bluetooth-Temperature-and-Humidity-Sensor>`__
by `@mspider65 <https://github.com/mspider65>`__
2018-08-24 22:44:01 +02:00
- `OpenMQTTGateway <https://github.com/1technophile/OpenMQTTGateway>`__ by `@1technophile <https://github.com/1technophile>`__
- :ghedit:`Edit`