Skip to content

Commit 1219996

Browse files
authored
Fixed _process_wosensorth() in __init__.py (#25)
This commit fixed bugs of _process_wosensorth(). - fixed wrong sign flag process - fixed KeyError caused by _wosensorth_data
1 parent a072d9c commit 1219996

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

switchbot/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ def _process_wosensorth(data) -> dict:
7777

7878
_sensor_data = binascii.unhexlify(data.encode())
7979

80-
_temp_sign = _sensor_data[4] & 0b10000000
80+
_temp_sign = 1 if _sensor_data[4] & 0b10000000 else -1
8181
_temp_c = _temp_sign * ((_sensor_data[4] & 0b01111111) + (_sensor_data[3] / 10))
8282
_temp_f = (_temp_c * 9 / 5) + 32
8383
_temp_f = (_temp_f * 10) / 10
8484

85+
_wosensorth_data["temp"] = {}
8586
_wosensorth_data["temp"]["c"] = _temp_c
8687
_wosensorth_data["temp"]["f"] = _temp_f
8788

0 commit comments

Comments
 (0)