Skip to content

Commit eaffaec

Browse files
committed
Add MJTZC01YM
1 parent 2c39576 commit eaffaec

File tree

5 files changed

+88
-2
lines changed

5 files changed

+88
-2
lines changed

Diff for: custom_components/ble_monitor/ble_parser/xiaomi.py

+27
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
0x3F4C: "PS1BB",
8282
0x3A61: "KS1",
8383
0x3E17: "KS1BP",
84+
0x3BD5: "MJTZC01YM"
8485
}
8586

8687
# Structured objects for data conversions
@@ -1222,6 +1223,31 @@ def obj5a16(xobj):
12221223
return None
12231224

12241225

1226+
def obj6e16(xobj):
1227+
"""Body Composition Scale"""
1228+
(profile_id, data, _) = struct.unpack("<BII", xobj)
1229+
if not data:
1230+
return None
1231+
1232+
result = {}
1233+
mass = data & 0x7FF
1234+
heart_rate = (data >> 11) & 0x7F
1235+
impedance = data >> 18
1236+
1237+
if mass != 0:
1238+
result.update({"weight": mass / 10})
1239+
if 0 < heart_rate < 127:
1240+
result.update({"heart rate": heart_rate + 50})
1241+
if impedance != 0:
1242+
if mass != 0:
1243+
result.update({"impedance": impedance / 10})
1244+
else:
1245+
result.update({"impedance low": impedance / 10})
1246+
1247+
result.update({"profile id": profile_id})
1248+
return result
1249+
1250+
12251251
# Dataobject dictionary
12261252
# {dataObject_id: (converter}
12271253
xiaomi_dataobject_dict = {
@@ -1301,6 +1327,7 @@ def obj5a16(xobj):
13011327
0x560d: obj560d,
13021328
0x560e: obj560e,
13031329
0x5a16: obj5a16,
1330+
0x6E16: obj6e16,
13041331
}
13051332

13061333

Diff for: custom_components/ble_monitor/const.py

+38
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,30 @@ class BLEMonitorBinarySensorEntityDescription(
14271427
suggested_display_precision=0,
14281428
state_class=SensorStateClass.MEASUREMENT,
14291429
),
1430+
BLEMonitorSensorEntityDescription(
1431+
key="heart_rate",
1432+
sensor_class="InstantUpdateSensor",
1433+
update_behavior="Instantly",
1434+
name="ble heart_rate",
1435+
unique_id="hr_",
1436+
icon="mdi:heart-pulse",
1437+
native_unit_of_measurement="bpm",
1438+
device_class=None,
1439+
suggested_display_precision=0,
1440+
state_class=SensorStateClass.MEASUREMENT,
1441+
),
1442+
BLEMonitorSensorEntityDescription(
1443+
key="profile id",
1444+
sensor_class="InstantUpdateSensor",
1445+
update_behavior="Instantly",
1446+
name="ble id",
1447+
unique_id="id_",
1448+
icon="mdi:counter",
1449+
native_unit_of_measurement=None,
1450+
device_class=None,
1451+
suggested_display_precision=0,
1452+
state_class=SensorStateClass.MEASUREMENT,
1453+
),
14301454
BLEMonitorSensorEntityDescription(
14311455
key="shake",
14321456
sensor_class="InstantUpdateSensor",
@@ -1463,6 +1487,18 @@ class BLEMonitorBinarySensorEntityDescription(
14631487
suggested_display_precision=1,
14641488
state_class=SensorStateClass.MEASUREMENT,
14651489
),
1490+
BLEMonitorSensorEntityDescription(
1491+
key="impedance low",
1492+
sensor_class="InstantUpdateSensor",
1493+
update_behavior="Instantly",
1494+
name="ble impedance low",
1495+
unique_id="im_low_",
1496+
icon="mdi:omega",
1497+
native_unit_of_measurement="Ohm",
1498+
device_class=None,
1499+
suggested_display_precision=1,
1500+
state_class=SensorStateClass.MEASUREMENT,
1501+
),
14661502
BLEMonitorSensorEntityDescription(
14671503
key="magnetic field",
14681504
sensor_class="InstantUpdateSensor",
@@ -1918,6 +1954,7 @@ class BLEMonitorBinarySensorEntityDescription(
19181954
'XMZNMS04LM' : [["battery", "rssi"], [], ["lock", "fingerprint"]],
19191955
'XMZNMS08LM' : [["battery", "rssi"], [], ["lock", "door"]],
19201956
'MJZNZ018H' : [["battery", "rssi"], ["button"], ["bed occupancy", "snoring", "sleeping"]],
1957+
'MJTZC01YM' : [["rssi", "heart rate"], ["weight", "impedance", "impedance low", "profile id"], []],
19211958
'ZX1' : [["rssi"], ["button"], ["bed occupancy", "snoring", "sleeping"]],
19221959
'CGC1' : [["temperature", "humidity", "battery", "rssi"], [], []],
19231960
'CGD1' : [["temperature", "humidity", "battery", "rssi"], [], []],
@@ -2051,6 +2088,7 @@ class BLEMonitorBinarySensorEntityDescription(
20512088
'ZNMS17LM' : 'Xiaomi Aqara',
20522089
'MJZNMSQ01YD' : 'Xiaomi',
20532090
'MJWSD05MMC' : 'Xiaomi',
2091+
'MJTZC01YM' : 'Xiaomi',
20542092
'XMZNMST02YD' : 'Xiaomi',
20552093
'XMZNMS04LM' : 'Xiaomi',
20562094
'XMZNMS08LM' : 'Xiaomi',

Diff for: custom_components/ble_monitor/sensor.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ class BaseSensor(RestoreSensor, SensorEntity):
360360
# | |**gyroscope
361361
# | |**MagneticFieldSensor
362362
# | |**MagneticFieldDirectionSensor
363-
# | |**ImpedanceSensor
363+
# | |**impedance
364+
# | |**impedance low
365+
# | |**profile id
364366
# | |--StateChangedSensor (Class)
365367
# | | |**mac
366368
# | | |**uuid
@@ -379,7 +381,6 @@ class BaseSensor(RestoreSensor, SensorEntity):
379381
# | | |**weight
380382
# | | |**stabilized weight
381383
# | | |**non-stabilized weight
382-
# | | |**impedance
383384
# | |--EnergySensor (Class)
384385
# | | |**energy
385386
# | |--PowerSensor (Class)

Diff for: docs/_devices/Xiaomi_MJTZC01YM.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
manufacturer: Xiaomi
3+
name: Body Composition Scale S400
4+
model: MJTZC01YM
5+
image: MJTZC01YM.png
6+
physical_description:
7+
broadcasted_properties:
8+
- weight
9+
- impedance
10+
- impedance low
11+
- heart rate
12+
- profile id
13+
- rssi
14+
broadcasted_property_notes:
15+
broadcast_rate:
16+
active_scan:
17+
encryption_key:
18+
custom_firmware:
19+
notes:
20+
---

Diff for: docs/assets/images/MJTZC01YM.png

27.2 KB
Loading

0 commit comments

Comments
 (0)