Combine xiaomi_miscale and xiaomi_miscale2 (#1458)

* Combine xiaomi_miscale and xiaomi_miscale2

* fix lint errors
This commit is contained in:
Robert Resch 2021-09-22 12:13:32 +02:00 committed by GitHub
parent 2dd8abcb1f
commit 2a103130df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 184 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -4,7 +4,7 @@ Xiaomi Miscale Sensors
.. seo:: .. seo::
:description: Instructions for setting up Xiaomi Miscale bluetooth-based sensors in ESPHome. :description: Instructions for setting up Xiaomi Miscale bluetooth-based sensors in ESPHome.
:image: xiaomi_miscale.jpg :image: xiaomi_miscale.jpg
:keywords: Xiaomi, BLE, Bluetooth, XMTZC01HM, XMTZC04HM :keywords: Xiaomi, Miscale, BLE, Bluetooth, XMTZC01HM, XMTZC04HM, XMTZC02HM, XMTZC05HM
The ``xiaomi_miscale`` sensor platform lets you track the output of Xiaomi Bluetooth Low Energy devices using the :doc:`/components/esp32_ble_tracker`. This component will track, for example, the weight of the device every time the sensor sends out a BLE broadcast. Contrary to other implementations, ``xiaomi_miscale`` listens passively to advertisement packets and does not pair with the device. Hence ESPHome has no impact on battery life. The ``xiaomi_miscale`` sensor platform lets you track the output of Xiaomi Bluetooth Low Energy devices using the :doc:`/components/esp32_ble_tracker`. This component will track, for example, the weight of the device every time the sensor sends out a BLE broadcast. Contrary to other implementations, ``xiaomi_miscale`` listens passively to advertisement packets and does not pair with the device. Hence ESPHome has no impact on battery life.
@ -13,26 +13,42 @@ To get the body scores using your weight, height, age and gender see the custom_
Supported Devices Supported Devices
----------------- -----------------
XMTZC01HM, XMTZC04HM XMTZC01HM, XMTZC04HM, XMTZC02HM, XMTZC05HM
******************** ******************************************
Miscale measures weight. Miscale (left) measures weight only. Miscale2 (right) measures weight and impedance.
.. figure:: images/xiaomi_miscale.jpg .. figure:: images/xiaomi_miscale.jpg
:align: center :align: center
:width: 60.0% :width: 60.0%
Configuration example:
.. code-block:: yaml .. code-block:: yaml
sensor: sensor:
- platform: xiaomi_miscale - platform: xiaomi_miscale
mac_address: 'C8:47:8C:9F:7B:0A' mac_address: '5C:CA:D3:70:D4:A2'
weight: weight:
name: "Xiaomi Mi Scale Weight" name: "Xiaomi Mi Scale Weight"
impedance:
name: "Xiaomi Mi Scale Impedance"
Configuration example with multiple users : Configuration variables:
------------------------
- **mac_address** (**Required**, MAC Address): The MAC address of the scale.
- **weight** (*Optional*): The information for the weight sensor.
- **name** (**Required**, string): The name for the weight sensor.
- All other options from :ref:`Sensor <config-sensor>`.
- **impedance** (*Optional*): The information for the impedance sensor. **Only available on MiScale2**
- **name** (**Required**, string): The name for the impedance sensor.
- All other options from :ref:`Sensor <config-sensor>`.
Configuration example with multiple users:
******************************************
You have to replace the numbers in the lambdas to determine your weight which is between X weight and X weight. You have to replace the numbers in the lambdas to determine your weight which is between X weight and X weight.
@ -40,23 +56,28 @@ You have to replace the numbers in the lambdas to determine your weight which is
sensor: sensor:
- platform: xiaomi_miscale - platform: xiaomi_miscale
mac_address: 'C8:47:8C:9F:7B:0A' mac_address: '5C:CA:D3:70:D4:A2'
weight: weight:
name: "Xiaomi Mi Scale Weight" name: "Xiaomi Mi Scale Weight"
id: weight_miscale id: weight_miscale
on_value: on_value:
then: then:
- lambda: |- - lambda: |-
if (id(weight_miscale).state >= 69 && id(weight_miscale).state <= 74.49) { if (id(weight_miscale).state >= 69 && id(weight_miscale).state <= 74.49) {
return id(weight_user1).publish_state(x);} return id(weight_user1).publish_state(x);}
else if (id(weight_miscale).state >= 74.50 && id(weight_miscale).state <= 83) { else if (id(weight_miscale).state >= 74.50 && id(weight_miscale).state <= 83) {
return id(weight_user2).publish_state(x);} return id(weight_user2).publish_state(x);}
else if (id(weight_miscale).state >= 46 && id(weight_miscale).state <= 65) {
return id(weight_user3).publish_state(x);} impedance:
else if (id(weight_miscale).state >= 28 && id(weight_miscale).state <= 45) { name: "Xiaomi Mi Scale Impedance"
return id(weight_user4).publish_state(x);} id: impedance_xiaomi
else if (id(weight_miscale).state >= 5 && id(weight_miscale).state <= 20) { on_value:
return id(weight_user5).publish_state(x);} then:
- lambda: |-
if (id(weight_miscale).state >= 69 && id(weight_miscale).state <= 74.49) {
return id(impedance_user1).publish_state(x);}
else if (id(weight_miscale).state >= 74.50 && id(weight_miscale).state <= 83) {
return id(impedance_user2).publish_state(x);}
- platform: template - platform: template
name: Weight Aurélien name: Weight Aurélien
@ -64,6 +85,12 @@ You have to replace the numbers in the lambdas to determine your weight which is
unit_of_measurement: 'kg' unit_of_measurement: 'kg'
icon: mdi:weight-kilogram icon: mdi:weight-kilogram
accuracy_decimals: 2 accuracy_decimals: 2
- platform: template
name: Impedance Aurélien
id: impedance_user1
unit_of_measurement: 'ohm'
icon: mdi:omega
accuracy_decimals: 0
- platform: template - platform: template
name: Weight Siham name: Weight Siham
id: weight_user2 id: weight_user2
@ -71,23 +98,11 @@ You have to replace the numbers in the lambdas to determine your weight which is
icon: mdi:weight-kilogram icon: mdi:weight-kilogram
accuracy_decimals: 2 accuracy_decimals: 2
- platform: template - platform: template
name: Weight Théo name: Impedance Siham
id: weight_user3 id: impedance_user2
unit_of_measurement: 'kg' unit_of_measurement: 'ohm'
icon: mdi:weight-kilogram icon: mdi:omega
accuracy_decimals: 2 accuracy_decimals: 0
- platform: template
name: Weight Sacha
id: weight_user4
unit_of_measurement: 'kg'
icon: mdi:weight-kilogram
accuracy_decimals: 2
- platform: template
name: Weight Noham
id: weight_user5
unit_of_measurement: 'kg'
icon: mdi:weight-kilogram
accuracy_decimals: 2
See Also See Also

View File

@ -1,150 +1,4 @@
Xiaomi Miscale2 Sensors Xiaomi Miscale2 combined into Xiaomi Miscale
======================== ============================================
.. seo:: :doc:`/components/sensor/xiaomi_miscale`
:description: Instructions for setting up Xiaomi Miscale2 bluetooth-based sensors in ESPHome.
:image: xiaomi_miscale2.jpg
:keywords: Xiaomi, BLE, Bluetooth, XMTZC02HM, XMTZC05HM
The ``xiaomi_miscale2`` sensor platform lets you track the output of Xiaomi Bluetooth Low Energy devices using the :doc:`/components/esp32_ble_tracker`. This component will track, for example, the weight and the impedance of the device every time the sensor sends out a BLE broadcast. Contrary to other implementations, ``xiaomi_miscale2`` listens passively to advertisement packets and does not pair with the device. Hence ESPHome has no impact on battery life.
To get the body scores using your weight, height, age and gender see the custom_components `<https://github.com/dckiller51/bodymiscale>`__
Supported Devices
-----------------
XMTZC02HM, XMTZC05HM
********************
Miscale2 measures weight and impedance.
.. figure:: images/xiaomi_miscale2.jpg
:align: center
:width: 60.0%
Configuration example:
.. code-block:: yaml
sensor:
- platform: xiaomi_miscale2
mac_address: '5C:CA:D3:70:D4:A2'
weight:
name: "Xiaomi Mi Scale Weight"
impedance:
name: "Xiaomi Mi Scale Impedance"
Configuration example with multiple users :
You have to replace the numbers in the lambdas to determine your weight which is between X weight and X weight.
.. code-block:: yaml
sensor:
- platform: xiaomi_miscale2
mac_address: '5C:CA:D3:70:D4:A2'
weight:
name: "Xiaomi Mi Scale Weight"
id: weight_miscale
on_value:
then:
- lambda: |-
if (id(weight_miscale).state >= 69 && id(weight_miscale).state <= 74.49) {
return id(weight_user1).publish_state(x);}
else if (id(weight_miscale).state >= 74.50 && id(weight_miscale).state <= 83) {
return id(weight_user2).publish_state(x);}
else if (id(weight_miscale).state >= 46 && id(weight_miscale).state <= 65) {
return id(weight_user3).publish_state(x);}
else if (id(weight_miscale).state >= 28 && id(weight_miscale).state <= 45) {
return id(weight_user4).publish_state(x);}
else if (id(weight_miscale).state >= 5 && id(weight_miscale).state <= 20) {
return id(weight_user5).publish_state(x);}
impedance:
name: "Xiaomi Mi Scale Impedance"
id: impedance_xiaomi
on_value:
then:
- lambda: |-
if (id(weight_miscale).state >= 69 && id(weight_miscale).state <= 74.49) {
return id(impedance_user1).publish_state(x);}
else if (id(weight_miscale).state >= 74.50 && id(weight_miscale).state <= 83) {
return id(impedance_user2).publish_state(x);}
else if (id(weight_miscale).state >= 46 && id(weight_miscale).state <= 65) {
return id(impedance_user3).publish_state(x);}
else if (id(weight_miscale).state >= 28 && id(weight_miscale).state <= 45) {
return id(impedance_user4).publish_state(x);}
else if (id(weight_miscale).state >= 5 && id(weight_miscale).state <= 20) {
return id(impedance_user5).publish_state(x);}
- platform: template
name: Weight Aurélien
id: weight_user1
unit_of_measurement: 'kg'
icon: mdi:weight-kilogram
accuracy_decimals: 2
- platform: template
name: Impedance Aurélien
id: impedance_user1
unit_of_measurement: 'ohm'
icon: mdi:omega
accuracy_decimals: 0
- platform: template
name: Weight Siham
id: weight_user2
unit_of_measurement: 'kg'
icon: mdi:weight-kilogram
accuracy_decimals: 2
- platform: template
name: Impedance Siham
id: impedance_user2
unit_of_measurement: 'ohm'
icon: mdi:omega
accuracy_decimals: 0
- platform: template
name: Weight Théo
id: weight_user3
unit_of_measurement: 'kg'
icon: mdi:weight-kilogram
accuracy_decimals: 2
- platform: template
name: Impedance Théo
id: impedance_user3
unit_of_measurement: 'ohm'
icon: mdi:omega
accuracy_decimals: 0
- platform: template
name: Weight Sacha
id: weight_user4
unit_of_measurement: 'kg'
icon: mdi:weight-kilogram
accuracy_decimals: 2
- platform: template
name: Impedance Sacha
id: impedance_user4
unit_of_measurement: 'ohm'
icon: mdi:omega
accuracy_decimals: 0
- platform: template
name: Weight Noham
id: weight_user5
unit_of_measurement: 'kg'
icon: mdi:weight-kilogram
accuracy_decimals: 2
- platform: template
name: Impedance Noham
id: impedance_user5
unit_of_measurement: 'ohm'
icon: mdi:omega
accuracy_decimals: 0
See Also
--------
- :doc:`/components/esp32_ble_tracker`
- :doc:`/components/sensor/index`
- bodymiscale score integration for Home Assistant (bodymiscale custom component) `<https://github.com/dckiller51/bodymiscale>`__
- bodymiscale Lovelace Card `<https://github.com/dckiller51/lovelace-body-miscale-card>`__
- :ghedit:`Edit`

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -349,8 +349,7 @@ Weight
.. imgtable:: .. imgtable::
HX711, components/sensor/hx711, hx711.jpg, Load cell amplifier HX711, components/sensor/hx711, hx711.jpg, Load cell amplifier
Xiaomi Miscale, components/sensor/xiaomi_miscale, xiaomi_miscale.jpg Xiaomi Miscale, components/sensor/xiaomi_miscale, xiaomi_miscale1&2.jpg
Xiaomi Miscale2, components/sensor/xiaomi_miscale2, xiaomi_miscale2.jpg
Looking for a sensor that outputs its values as an analog voltage? Have a look at the Looking for a sensor that outputs its values as an analog voltage? Have a look at the