Skip to content

Commit 6d586ed

Browse files
committed
fix(tion): fix temperature decoding.
1 parent fbf9eaa commit 6d586ed

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

tests/decode_temperature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
88
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
99

10-
import tion
10+
from tion_btle import tion
1111

1212

1313
class TestDecodeTemperature(unittest.TestCase, tion.tion):

tion_btle/tion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ def decode_temperature(self, raw: bytes) -> int:
106106
Integer value for temperature
107107
"""
108108
barrier = 0b10000000
109-
if (raw < barrier):
109+
if int(raw) < barrier:
110110
result = raw
111111
else:
112-
result = -(~(result - barrier) + barrier + 1)
112+
result = -(~(raw - barrier) + barrier + 1)
113113

114114
return result
115115

0 commit comments

Comments
 (0)