Skip to content

Commit a219308

Browse files
authored
Merge pull request #1322 from yoavf/fix/smartdry-errors
smartdry: fix parsing when some information is missing
2 parents 3120c4e + d1e82b9 commit a219308

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

custom_components/ble_monitor/ble_parser/smartdry.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,28 @@ def parse_smartdry(self, data: bytes, mac: str):
3535
else:
3636
volt = None
3737

38-
if volt >= 3.00:
39-
batt = 100
40-
elif volt >= 2.60:
41-
batt = 60 + (volt - 2.60) * 100
42-
elif volt >= 2.50:
43-
batt = 40 + (volt - 2.50) * 200
44-
elif volt >= 2.45:
45-
batt = 20 + (volt - 2.45) * 400
46-
else:
47-
batt = 0
48-
if volt:
38+
batt = None
39+
40+
if volt is not None:
41+
if volt >= 3.00:
42+
batt = 100
43+
elif volt >= 2.60:
44+
batt = 60 + (volt - 2.60) * 100
45+
elif volt >= 2.50:
46+
batt = 40 + (volt - 2.50) * 200
47+
elif volt >= 2.45:
48+
batt = 20 + (volt - 2.45) * 400
49+
else:
50+
batt = 0
51+
52+
if volt is not None:
4953
result.update({
5054
"voltage": volt,
5155
"battery": batt
5256
})
5357
else:
5458
device_type = None
59+
firmware = None
5560
if device_type is None:
5661
if self.report_unknown == "SmartDry":
5762
_LOGGER.info(

0 commit comments

Comments
 (0)