Skip to content

Add MJTZC01YM #1453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions custom_components/ble_monitor/ble_parser/xiaomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
0x3F4C: "PS1BB",
0x3A61: "KS1",
0x3E17: "KS1BP",
0x3BD5: "MJTZC01YM",
0x50FB: "ES3",
0x5DB1: "MBS17"
}
Expand Down Expand Up @@ -1252,6 +1253,31 @@ def obj5a16(xobj):
return None


def obj6e16(xobj):
"""Body Composition Scale"""
(profile_id, data, _) = struct.unpack("<BII", xobj)
if not data:
return None

result = {}
mass = data & 0x7FF
heart_rate = (data >> 11) & 0x7F
impedance = data >> 18

if mass != 0:
result.update({"weight": mass / 10})
if 0 < heart_rate < 127:
result.update({"heart rate": heart_rate + 50})
if impedance != 0:
if mass != 0:
result.update({"impedance": impedance / 10})
else:
result.update({"impedance low": impedance / 10})

result.update({"profile id": profile_id})
return result


# Dataobject dictionary
# {dataObject_id: (converter}
xiaomi_dataobject_dict = {
Expand Down Expand Up @@ -1334,6 +1360,7 @@ def obj5a16(xobj):
0x560d: obj560d,
0x560e: obj560e,
0x5a16: obj5a16,
0x6E16: obj6e16,
}


Expand Down
38 changes: 38 additions & 0 deletions custom_components/ble_monitor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,30 @@ class BLEMonitorBinarySensorEntityDescription(
suggested_display_precision=0,
state_class=SensorStateClass.MEASUREMENT,
),
BLEMonitorSensorEntityDescription(
key="heart_rate",
sensor_class="InstantUpdateSensor",
update_behavior="Instantly",
name="ble heart_rate",
unique_id="hr_",
icon="mdi:heart-pulse",
native_unit_of_measurement="bpm",
device_class=None,
suggested_display_precision=0,
state_class=SensorStateClass.MEASUREMENT,
),
BLEMonitorSensorEntityDescription(
key="profile id",
sensor_class="InstantUpdateSensor",
update_behavior="Instantly",
name="ble id",
unique_id="id_",
icon="mdi:counter",
native_unit_of_measurement=None,
device_class=None,
suggested_display_precision=0,
state_class=SensorStateClass.MEASUREMENT,
),
BLEMonitorSensorEntityDescription(
key="shake",
sensor_class="InstantUpdateSensor",
Expand Down Expand Up @@ -1463,6 +1487,18 @@ class BLEMonitorBinarySensorEntityDescription(
suggested_display_precision=1,
state_class=SensorStateClass.MEASUREMENT,
),
BLEMonitorSensorEntityDescription(
key="impedance low",
sensor_class="InstantUpdateSensor",
update_behavior="Instantly",
name="ble impedance low",
unique_id="im_low_",
icon="mdi:omega",
native_unit_of_measurement="Ohm",
device_class=None,
suggested_display_precision=1,
state_class=SensorStateClass.MEASUREMENT,
),
BLEMonitorSensorEntityDescription(
key="magnetic field",
sensor_class="InstantUpdateSensor",
Expand Down Expand Up @@ -1919,6 +1955,7 @@ class BLEMonitorBinarySensorEntityDescription(
'XMZNMS04LM' : [["battery", "rssi"], [], ["lock", "fingerprint"]],
'XMZNMS08LM' : [["battery", "rssi"], [], ["lock", "door"]],
'MJZNZ018H' : [["battery", "rssi"], ["button"], ["bed occupancy", "snoring", "sleeping"]],
'MJTZC01YM' : [["rssi", "heart rate"], ["weight", "impedance", "impedance low", "profile id"], []],
'ZX1' : [["rssi"], ["button"], ["bed occupancy", "snoring", "sleeping"]],
'CGC1' : [["temperature", "humidity", "battery", "rssi"], [], []],
'CGD1' : [["temperature", "humidity", "battery", "rssi"], [], []],
Expand Down Expand Up @@ -2052,6 +2089,7 @@ class BLEMonitorBinarySensorEntityDescription(
'ZNMS17LM' : 'Xiaomi Aqara',
'MJZNMSQ01YD' : 'Xiaomi',
'MJWSD05MMC' : 'Xiaomi',
'MJTZC01YM' : 'Xiaomi',
'XMZNMST02YD' : 'Xiaomi',
'XMZNMS04LM' : 'Xiaomi',
'XMZNMS08LM' : 'Xiaomi',
Expand Down
5 changes: 3 additions & 2 deletions custom_components/ble_monitor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ class BaseSensor(RestoreSensor, SensorEntity):
# | |**gyroscope
# | |**MagneticFieldSensor
# | |**MagneticFieldDirectionSensor
# | |**ImpedanceSensor
# | |**impedance
# | |**impedance low
# | |**profile id
# | |--StateChangedSensor (Class)
# | | |**mac
# | | |**uuid
Expand All @@ -379,7 +381,6 @@ class BaseSensor(RestoreSensor, SensorEntity):
# | | |**weight
# | | |**stabilized weight
# | | |**non-stabilized weight
# | | |**impedance
# | |--EnergySensor (Class)
# | | |**energy
# | |--PowerSensor (Class)
Expand Down
20 changes: 20 additions & 0 deletions docs/_devices/Xiaomi_MJTZC01YM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
manufacturer: Xiaomi
name: Body Composition Scale S400
model: MJTZC01YM
image: MJTZC01YM.png
physical_description:
broadcasted_properties:
- weight
- impedance
- impedance low
- heart rate
- profile id
- rssi
broadcasted_property_notes:
broadcast_rate:
active_scan:
encryption_key:
custom_firmware:
notes:
---
Binary file added docs/assets/images/MJTZC01YM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading