Skip to content

Commit 6c205f9

Browse files
Merge pull request #468 from WillCodeForCats/new-entity-checks
Raise TypeError from struct.error in helper
2 parents 6e549f2 + f08890d commit 6c205f9

File tree

1 file changed

+4
-1
lines changed
  • custom_components/solaredge_modbus_multi

1 file changed

+4
-1
lines changed

custom_components/solaredge_modbus_multi/helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def scale_factor(value: int, sf: int):
1414

1515

1616
def float_to_hex(f):
17-
return hex(struct.unpack("<I", struct.pack("<f", f))[0])
17+
try:
18+
return hex(struct.unpack("<I", struct.pack("<f", f))[0])
19+
except struct.error as e:
20+
raise TypeError(e)
1821

1922

2023
def parse_modbus_string(s: str) -> str:

0 commit comments

Comments
 (0)