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

Add battery low data to Thermopro #1441

Merged
merged 3 commits into from
Mar 9, 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
13 changes: 9 additions & 4 deletions custom_components/ble_monitor/ble_parser/thermopro.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ def parse_thermopro(self, data: bytes, device_type, mac: bytes):
"""Thermopro parser"""
if device_type in ["TP357", "TP359"]:
firmware = "Thermopro"
xvalue = data[3:6]
(temp, humi) = unpack("<hB", xvalue)
xvalue = data[3:7]
(temp, humi, batt) = unpack("<hBB", xvalue)
if batt == 2:
# full battery
batt_low = 0
else:
# low battery
batt_low = 1
result = {
"temperature": temp / 10,
"humidity": humi,
"battery low": batt_low
}
else:
device_type = None
if device_type is None:
if self.report_unknown == "Thermopro":
_LOGGER.info(
"BLE ADV from UNKNOWN Thermopro DEVICE: MAC: %s, ADV: %s",
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.3.0",
"pyric>=0.1.6.3"
],
"version": "13.0.2"
"version": "13.0.3"
}
1 change: 1 addition & 0 deletions custom_components/ble_monitor/test/test_thermopro.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_thermopro_tp357(self):
assert sensor_msg["data"]
assert sensor_msg["temperature"] == 27.9
assert sensor_msg["humidity"] == 39
assert sensor_msg["battery low"] == 0
assert sensor_msg["rssi"] == -68

def test_thermopro_tp359(self):
Expand Down
Loading