diff --git a/custom_components/ble_monitor/ble_parser/mocreo.py b/custom_components/ble_monitor/ble_parser/mocreo.py index 06a0e1988..e829036bb 100644 --- a/custom_components/ble_monitor/ble_parser/mocreo.py +++ b/custom_components/ble_monitor/ble_parser/mocreo.py @@ -16,6 +16,7 @@ 0x87: "ST10", 0x8B: "MS1", 0x94: "MS2", + 0x95: "SD1", 0x96: "MS3", } @@ -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), }, @@ -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 diff --git a/custom_components/ble_monitor/const.py b/custom_components/ble_monitor/const.py index 6618e6a01..cff71a6a5 100644 --- a/custom_components/ble_monitor/const.py +++ b/custom_components/ble_monitor/const.py @@ -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"], []], @@ -2364,6 +2365,7 @@ class BLEMonitorBinarySensorEntityDescription( 'ST10' : 'MOCREO', 'MS1' : 'MOCREO', 'MS2' : 'MOCREO', + 'SD1' : 'MOCREO', 'MS3' : 'MOCREO', 'TMS' : 'Michelin', 'S-MATE' : 'Sonoff', diff --git a/custom_components/ble_monitor/test/test_mocreo_parser.py b/custom_components/ble_monitor/test/test_mocreo_parser.py index 3dc6bcde9..1db2ac8b0 100644 --- a/custom_components/ble_monitor/test/test_mocreo_parser.py +++ b/custom_components/ble_monitor/test/test_mocreo_parser.py @@ -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"