Skip to content
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

Relsib WH52 #1402

Merged
merged 5 commits into from
Nov 9, 2024
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
4 changes: 4 additions & 0 deletions custom_components/ble_monitor/ble_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def parse_advertisement(
uuid16 = (service_data[3] << 8) | service_data[2]
if uuid16 == 0x1809:
# UUID16 = Health Thermometer service (used by Relsib)
if len(service_data_list) == 3:
uuid16_2 = (service_data_list[1][3] << 8) | service_data_list[1][2]
if uuid16_2 == 0x181A:
service_data = b"".join(service_data_list)
sensor_data = parse_relsib(self, service_data, mac)
break
if uuid16 == 0x181A:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/acconeer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}


def parse_acconeer(self, data: bytes, mac: str):
def parse_acconeer(self, data: bytes, mac: bytes):
"""Acconeer parser"""
msg_length = len(data)
firmware = "Acconeer"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/airmentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def parse_2s(msg_type, xvalue):
return None


def parse_airmentor(self, data: bytes, mac: str):
def parse_airmentor(self, data: bytes, mac: bytes):
"""Parser for Air Mentor"""
data_length = len(data)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/almendo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_almendo(self, data: bytes, mac: str):
def parse_almendo(self, data: bytes, mac: bytes):
"""Almendo parser"""
result = {
"mac": to_unformatted_mac(mac),
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/altbeacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
DEVICE_TYPE: Final = "AltBeacon"


def parse_altbeacon(self, data: str, comp_id: int, mac: str):
def parse_altbeacon(self, data: bytes, comp_id: int, mac: bytes):
"""parser for Alt Beacon"""
if len(data) >= 27:
uuid = data[6:22]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/amazfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_amazfit(self, service_data: str, man_spec_data: str, mac: str):
def parse_amazfit(self, service_data: str | None, man_spec_data: str, mac: bytes):
"""parser for Amazfit scale and Miband 4 and 5"""
if service_data:
service_data_length = len(service_data)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/atc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_atc(self, data: bytes, mac: str):
def parse_atc(self, data: bytes, mac: bytes):
"""Parse ATC BLE advertisements"""
device_type = "ATC"
msg_length = len(data)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/bluemaestro.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_bluemaestro(self, data: bytes, mac: str):
def parse_bluemaestro(self, data: bytes, mac: bytes):
"""Parse BlueMaestro advertisement."""
msg_length = len(data)
firmware = "BlueMaestro"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/blustream.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_blustream(self, data: bytes, mac: str):
def parse_blustream(self, data: bytes, mac: bytes):
"""Parse Blustream advertisement."""
msg_length = len(data)
firmware = "Blustream"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/bparasite.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_bparasite(self, data: bytes, mac: str):
def parse_bparasite(self, data: bytes, mac: bytes):
"""Check for adstruc length"""
msg_length = len(data)
if msg_length == 22: # TODO: Use protocol bits?
Expand Down
6 changes: 3 additions & 3 deletions custom_components/ble_monitor/ble_parser/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
from uuid import UUID


def to_uuid(uuid: str) -> str:
def to_uuid(uuid: bytes) -> str:
"""Return formatted UUID"""
return str(UUID(''.join(f'{i:02X}' for i in uuid)))


def to_mac(addr: str) -> str:
def to_mac(addr: bytes) -> str:
"""Return formatted MAC address"""
return ':'.join(f'{i:02X}' for i in addr)


def to_unformatted_mac(addr: str) -> str:
def to_unformatted_mac(addr: bytes) -> str:
"""Return unformatted MAC address"""
return ''.join(f'{i:02X}' for i in addr[:])
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/ibeacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
DEVICE_TYPE: Final = "iBeacon"


def parse_ibeacon(self, data: str, mac: str):
def parse_ibeacon(self, data: bytes, mac: bytes):
"""Parse iBeacon advertisements"""
if data[5] == 0x15 and len(data) >= 27:
uuid = data[6:22]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/inkbird.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def convert_temperature(temp):
return temperature


def parse_inkbird(self, data: bytes, complete_local_name: str, mac: str):
def parse_inkbird(self, data: bytes, complete_local_name: str, mac: bytes):
"""Inkbird parser"""
msg_length = len(data)
firmware = "Inkbird"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/inode.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def adj_acc(acc):
return acc


def parse_inode(self, data: bytes, mac: str):
def parse_inode(self, data: bytes, mac: bytes):
"""iNode parser"""
msg_length = len(data)
firmware = "iNode"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/jaalee.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_jaalee(self, data: bytes, mac: str):
def parse_jaalee(self, data: bytes, mac: bytes):
"""Jaalee parser"""
msg_length = len(data)
firmware = "Jaalee"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/jinou.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_jinou(self, data: bytes, mac: str):
def parse_jinou(self, data: bytes, mac: bytes):
"""Jinou parser"""
msg_length = len(data)
firmware = "Jinou"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/kegtron.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}


def parse_kegtron(self, data: bytes, mac: str):
def parse_kegtron(self, data: bytes, mac: bytes):
"""Parser for Kegtron sensors"""
msg_length = len(data)
if msg_length == 31:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/kkm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_kkm(self, data: bytes, mac: str):
def parse_kkm(self, data: bytes, mac: bytes):
"""Parser for KKM sensors."""
device_type = "K6 Sensor Beacon"
result = {
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/laica.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def read_impedance(data):
return impedance


def parse_laica(self, data: bytes, mac: str):
def parse_laica(self, data: bytes, mac: bytes):
"""Parser for Laica sensors"""
xvalue = data[4:]

Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/mikrotik.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def convert_8_8_to_float(val_1, val_2):
return val_1 + (val_2 / 256)


def parse_mikrotik(self, data: bytes, mac: str):
def parse_mikrotik(self, data: bytes, mac: bytes):
"""Inkbird parser"""
msg_length = len(data)
firmware = "Mikrotik"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/miscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_miscale(self, data: bytes, mac: str):
def parse_miscale(self, data: bytes, mac: bytes):
"""Parser for Xiaomi Mi Scales."""
msg_length = len(data)
uuid16 = (data[3] << 8) | data[2]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/moat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_moat(self, data: bytes, mac: str):
def parse_moat(self, data: bytes, mac: bytes):
"""Parser for Moat sensors"""
msg_length = len(data)
firmware = "Moat"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/oral_b.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}


def parse_oral_b(self, data: bytes, mac: str):
def parse_oral_b(self, data: bytes, mac: bytes):
"""Parser for Oral-B toothbrush."""
msg_length = len(data)
firmware = "Oral-B"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/oras.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}


def parse_oras(self, data: bytes, mac: str):
def parse_oras(self, data: bytes, mac: bytes):
"""Parser for Oras toothbrush or Garnet tank."""
msg_length = len(data)
result = {"mac": to_unformatted_mac(mac)}
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/qingping.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_qingping(self, data: bytes, mac: str):
def parse_qingping(self, data: bytes, mac: bytes):
"""Qingping parser"""
msg_length = len(data)
if msg_length > 12:
Expand Down
10 changes: 9 additions & 1 deletion custom_components/ble_monitor/ble_parser/relsib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_relsib(self, data: bytes, mac: str):
def parse_relsib(self, data: bytes, mac: bytes):
"""Relsib parser"""
msg_length = len(data)
uuid16 = (data[3] << 8) | data[2]
Expand Down Expand Up @@ -43,6 +43,14 @@ def parse_relsib(self, data: bytes, mac: str):
result.update({"battery": 100})
else:
result.update({"battery": battery & 0b01111111})
elif uuid16 in [0x1809] and msg_length == 20:
device_type = "WH52"
try:
temp = round((int.from_bytes(data[4:6], byteorder='big') / 65535) * 175 - 45, 2)
humi = round((int.from_bytes(data[10:12], byteorder='big') / 65535) * 175 - 45, 2)
result.update({"temperature": temp, "humidity": humi})
except ValueError:
device_type = None
elif uuid16 in [0x1809] and msg_length == 10:
device_type = "WT51"
try:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/ruuvitag.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_ruuvitag(self, data: bytes, mac: str):
def parse_ruuvitag(self, data: bytes, mac: bytes):
"""Ruuvitag parser"""
device_type = "Ruuvitag"
result = {
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/sensirion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]


def parse_sensirion(self, data: bytes, complete_local_name: str, mac: str):
def parse_sensirion(self, data: bytes, complete_local_name: str, mac: bytes):
"""Sensirion parser"""
result = {"firmware": "Sensirion"}
device_type = complete_local_name
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/sensorpush.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def decode_values(mfg_data: bytes, device_type_id: int) -> dict:
return values


def parse_sensorpush(self, data: bytes, mac: str):
def parse_sensorpush(self, data: bytes, mac: bytes):
"""Sensorpush parser"""
result = {"firmware": "SensorPush"}
device_type = None
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/senssun.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def read_stable(ctr1):
"""Parse Stable"""
return int((ctr1 & 0xA0) == 0xA0)

def parse_senssun(self, data: bytes, mac: str):
def parse_senssun(self, data: bytes, mac: bytes):
"""Parser for Senssun Scales."""
xvalue = data[13:19]

Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/smartdry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_smartdry(self, data: bytes, mac: str):
def parse_smartdry(self, data: bytes, mac: bytes):
"""Parser for SmartDry cloth dryer"""
msg_length = len(data)
if msg_length == 16:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/switchbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_switchbot(self, data: bytes, mac: str):
def parse_switchbot(self, data: bytes, mac: bytes):
"""Switchbot parser"""
msg_length = len(data)
device_id = data[4]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/teltonika.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_teltonika(self, data: bytes, complete_local_name: str, mac: str):
def parse_teltonika(self, data: bytes, complete_local_name: str, mac: bytes):
"""Teltonika parser"""
result = {"firmware": "Teltonika"}
device_id = (data[3] << 8) | data[2]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/thermobeacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_thermobeacon(self, data: bytes, mac: str):
def parse_thermobeacon(self, data: bytes, mac: bytes):
"""Thermobeacon parser"""
msg_length = len(data)
device_id = data[2]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/thermopro.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_thermopro(self, data: bytes, device_type, mac: str):
def parse_thermopro(self, data: bytes, device_type, mac: bytes):
"""Thermopro parser"""
if device_type in ["TP357", "TP359"]:
firmware = "Thermopro"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/tilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_tilt(self, data: bytes, mac: str, ):
def parse_tilt(self, data: bytes, mac: bytes):
"""Tilt parser"""
if data[5] == 0x15 and len(data) == 27:
uuid = data[6:22]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/xiaogui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_LOGGER = logging.getLogger(__name__)


def parse_xiaogui(self, data: bytes, mac: str):
def parse_xiaogui(self, data: bytes, mac: bytes):
"""Xiaogui Scales parser"""
msg_length = len(data)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/xiaomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ def obj5a16(xobj):
}


def parse_xiaomi(self, data: bytes, mac: str):
def parse_xiaomi(self, data: bytes, mac: bytes):
"""Parser for Xiaomi sensors"""
# check for adstruc length
i = 9 # till Frame Counter
Expand Down
1 change: 1 addition & 0 deletions custom_components/ble_monitor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,7 @@ class BLEMonitorBinarySensorEntityDescription(
'CGP23W' : 'Qingping',
'EClerk Eco' : 'Relsib',
'WT51' : 'Relsib',
'WH52' : 'Relsib',
'Blue Puck T' : 'Teltonika',
'Blue Coin T' : 'Teltonika',
'Blue Puck RHT' : 'Teltonika',
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"btsocket>=0.2.0",
"pyric>=0.1.6.3"
],
"version": "12.17.0"
"version": "12.18.0"
}
Loading
Loading