Skip to content

Commit

Permalink
feat(temp-spike): battery tweaks for TP96x (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
h3ss authored Jan 18, 2024
1 parent c9c11fc commit 19c07bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/thermopro_ble/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
UNPACK_SPIKE_TEMP = Struct("<BHHH").unpack

TP96_MAX_BAT = 2880
TP96_MIN_BAT = 1600 # ??
TP96_MIN_BAT = 2000 # ??


class ThermoProBluetoothDeviceData(BluetoothData):
Expand Down Expand Up @@ -82,6 +82,8 @@ def _start_update(self, service_info: BluetoothServiceInfo) -> None:
internal_temp = internal_temp - 30
ambient_temp = ambient_temp - 30
battery_percent = ((battery - TP96_MIN_BAT) / bat_range) * 100
if battery_percent > 100:
battery_percent = 100
self.update_predefined_sensor(
SensorLibrary.TEMPERATURE__CELSIUS,
internal_temp,
Expand Down
10 changes: 5 additions & 5 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def test_tp960r():
DeviceKey(key="battery_probe_1", device_id=None): SensorValue(
device_key=DeviceKey(key="battery_probe_1", device_id=None),
name="Probe 1 Battery",
native_value=39,
native_value=11,
),
},
binary_entity_descriptions={},
Expand Down Expand Up @@ -405,7 +405,7 @@ def test_tp960r():
DeviceKey(key="battery_probe_1", device_id=None): SensorValue(
device_key=DeviceKey(key="battery_probe_1", device_id=None),
name="Probe 1 Battery",
native_value=39,
native_value=11,
),
},
binary_entity_descriptions={},
Expand Down Expand Up @@ -475,7 +475,7 @@ def test_tp962r():
DeviceKey(key="battery_probe_2", device_id=None): SensorValue(
device_key=DeviceKey(key="battery_probe_2", device_id=None),
name="Probe 2 Battery",
native_value=100,
native_value=99,
),
},
binary_entity_descriptions={},
Expand Down Expand Up @@ -567,12 +567,12 @@ def test_tp962r():
DeviceKey(key="battery_probe_1", device_id=None): SensorValue(
device_key=DeviceKey(key="battery_probe_1", device_id=None),
name="Probe 1 Battery",
native_value=77,
native_value=66,
),
DeviceKey(key="battery_probe_2", device_id=None): SensorValue(
device_key=DeviceKey(key="battery_probe_2", device_id=None),
name="Probe 2 Battery",
native_value=100,
native_value=99,
),
DeviceKey(key="internal_temperature_probe_2", device_id=None): SensorValue(
device_key=DeviceKey(
Expand Down

0 comments on commit 19c07bf

Please sign in to comment.