Skip to content
Open
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
8 changes: 8 additions & 0 deletions custom_components/ble_monitor/ble_parser/mocreo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
0x87: "ST10",
0x8B: "MS1",
0x94: "MS2",
0x95: "SD1",
0x96: "MS3",
}

Expand Down Expand Up @@ -57,6 +58,11 @@
0x94: {
"temperature": (6, 0, -16, True, lambda x: x / 100),
},
0x95: {
"temperature": (6, 0, -16, True, lambda x: x / 100),
"temperature probe 2": (8, 0, -16, True, lambda x: x / 100),
"door": (10, 5, 1, False, None),
},
0x96: {
"temperature": (6, 0, -16, True, lambda x: x / 100),
},
Expand Down Expand Up @@ -110,6 +116,8 @@ def parse_mocreo(self, data: bytes, local_name: str, mac: bytes):
data_parsing_format = MOCREO_TYPE_DATA_PARSING_FORMAT[device_type]
for key, value in data_parsing_format.items():
result[key] = _get_value(common_data, value)
if device_type == 0x95:
result["humidity"] = (((common_data[10] >> 4) << 8) | common_data[11]) / 10
result.update({
"battery": battery,
"data": True
Expand Down
2 changes: 2 additions & 0 deletions custom_components/ble_monitor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,7 @@ class BLEMonitorBinarySensorEntityDescription(
'ST10' : [["temperature", "battery", "rssi"], [], []],
'MS1' : [["temperature", "battery", "rssi"], [], []],
'MS2' : [["temperature", "battery", "rssi"], [], []],
'SD1' : [["temperature", "temperature probe 2", "humidity", "battery", "rssi"], [], ["door"]],
'MS3' : [["temperature", "battery", "rssi"], [], []],
'TMS' : [["temperature", "voltage", "pressure", "count", "steps", "text", "rssi"], [], []],
'S-MATE' : [["rssi"], ["three btn switch left", "three btn switch middle", "three btn switch right"], []],
Expand Down Expand Up @@ -2364,6 +2365,7 @@ class BLEMonitorBinarySensorEntityDescription(
'ST10' : 'MOCREO',
'MS1' : 'MOCREO',
'MS2' : 'MOCREO',
'SD1' : 'MOCREO',
'MS3' : 'MOCREO',
'TMS' : 'Michelin',
'S-MATE' : 'Sonoff',
Expand Down
21 changes: 21 additions & 0 deletions custom_components/ble_monitor/test/test_mocreo_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,27 @@ def test_MOCREO_MS2(self):
assert sensor_msg["data"]
assert sensor_msg["rssi"] == -42

def test_MOCREO_SD1(self):
"""Test MOCREO parser for SD1."""
data_string = "043e2b02010001bbaa00a4ae301f02010607094d4f4352454f13ff41950a00e4b09209b80b35e8000000000000d6"
data = bytes(bytearray.fromhex(data_string))

# pylint: disable=unused-variable
ble_parser = BleParser()
sensor_msg, tracker_msg = ble_parser.parse_raw_data(data)
assert sensor_msg["firmware"] == "MOCREO"
assert sensor_msg["type"] == "SD1"
assert sensor_msg["mac"] == "30AEA400AABB"
assert sensor_msg["packet"] == "no packet id"
assert sensor_msg["temperature"] == 24.5
assert sensor_msg["temperature probe 2"] == 30.0
assert sensor_msg["humidity"] == 100.0
assert "water leak" not in sensor_msg
assert sensor_msg["door"] == 1
assert sensor_msg["battery"] == 100
assert sensor_msg["data"]
assert sensor_msg["rssi"] == -42

def test_MOCREO_SW2(self):
"""Test MOCREO parser for SW2."""
data_string = "043e2b02010001bbaa00a4ae301f02010607094d4f4352454f13ff01821580e4000000000000000086f6000000c1"
Expand Down