Skip to content

Commit 83dc355

Browse files
committed
add tanks
1 parent b6314a0 commit 83dc355

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

custom_components/ble_monitor/ble_parser/oras.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55

66
_LOGGER = logging.getLogger(__name__)
77

8+
SENSOR_TYPE = {
9+
0: "fresh tank",
10+
1: "black tank",
11+
2: "grey tank",
12+
3: "LPG tank",
13+
4: "LPG tank 2",
14+
5: "galley tank",
15+
6: "galley tank 2",
16+
7: "temperature",
17+
8: "temperature 2",
18+
9: "temperature 3",
19+
10: "temperature 4",
20+
11: "chemical tank",
21+
12: "chemical tank 2",
22+
13: "voltage",
23+
}
24+
825

926
def parse_oras(self, data: bytes, mac: str):
1027
"""Parser for Oras toothbrush or Garnet tank."""
@@ -13,7 +30,7 @@ def parse_oras(self, data: bytes, mac: str):
1330

1431
if msg_length == 18:
1532
firmware = "Garnet"
16-
device_type = "Garnet 709BT"
33+
device_type = "SeeLevel II 709-BTP3"
1734

1835
sensor_id = data[7]
1936
sensor_data = data[8:11].decode("ASCII")
@@ -34,7 +51,9 @@ def parse_oras(self, data: bytes, mac: str):
3451
device_type,
3552
result
3653
)
37-
if sensor_id == 13:
54+
if sensor_id <= 12:
55+
result.update({SENSOR_TYPE[sensor_id]: int(sensor_data)})
56+
elif sensor_id == 13:
3857
result.update({"voltage": int(sensor_data) / 10})
3958
elif msg_length == 22:
4059
firmware = "Oras"

custom_components/ble_monitor/const.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ class BLEMonitorBinarySensorEntityDescription(
19221922
'Blustream' : 'Blustream',
19231923
'BTHome' : 'BTHome',
19241924
'CQ60' : 'Chef iQ',
1925-
'Garnet 709BT' : 'Garnet',
1925+
'SeeLevel II 709-BTP3' : 'Garnet Instruments Ltd',
19261926
'MI401' : 'Grundfos',
19271927
'HHCCJCY10' : 'HHCC',
19281928
'HolyIOT BLE tracker' : 'HolyIOT',

custom_components/ble_monitor/test/test_oras.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_oras_faucet(self):
2020
assert sensor_msg["battery"] == 100
2121
assert sensor_msg["rssi"] == -52
2222

23-
def test_garmet_battery(self):
23+
def test_garnet_battery(self):
2424
"""Test Oras parser for Garnet 709BT battery sensor."""
2525
data_string = "043E2102010000adb9a538c1a41502010611ff31010c464e0d31333230303030303030CC"
2626
data = bytes(bytearray.fromhex(data_string))
@@ -29,9 +29,25 @@ def test_garmet_battery(self):
2929
sensor_msg, tracker_msg = ble_parser.parse_raw_data(data)
3030

3131
assert sensor_msg["firmware"] == "Garnet"
32-
assert sensor_msg["type"] == "Garnet 709BT"
32+
assert sensor_msg["type"] == "SeeLevel II 709-BTP3"
3333
assert sensor_msg["mac"] == "A4C138A5B9AD"
3434
assert sensor_msg["packet"] == "no packet id"
3535
assert sensor_msg["data"]
3636
assert sensor_msg["voltage"] == 13.2
3737
assert sensor_msg["rssi"] == -52
38+
39+
def test_garnet_black_tank(self):
40+
"""Test Oras parser for Garnet 709BT black tank sensor."""
41+
data_string = "043E2102010000adb9a538c1a41502010611ff31010c464e0120373130303030303030CC"
42+
data = bytes(bytearray.fromhex(data_string))
43+
# pylint: disable=unused-variable
44+
ble_parser = BleParser()
45+
sensor_msg, tracker_msg = ble_parser.parse_raw_data(data)
46+
47+
assert sensor_msg["firmware"] == "Garnet"
48+
assert sensor_msg["type"] == "SeeLevel II 709-BTP3"
49+
assert sensor_msg["mac"] == "A4C138A5B9AD"
50+
assert sensor_msg["packet"] == "no packet id"
51+
assert sensor_msg["data"]
52+
assert sensor_msg["black tank"] == 71
53+
assert sensor_msg["rssi"] == -52

0 commit comments

Comments
 (0)