Skip to content

Commit

Permalink
proper data types
Browse files Browse the repository at this point in the history
Signed-off-by: Travis Glenn Hansen <[email protected]>
  • Loading branch information
travisghansen committed Jan 30, 2023
1 parent 978db5e commit 0931c36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.5.13

Released 2023-01-29

- ensure proper data type

# v0.5.12

Released 2023-01-29
Expand Down
7 changes: 6 additions & 1 deletion custom_components/pfsense/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,12 @@ def native_value(self):
value = gateway[property]
# cleanse "ms", etc from values
if property in ["stddev", "delay", "loss"]:
value = re.sub("[^0-9\.]*", "", value)
if isinstance(value, str):
value = re.sub("[^0-9\.]*", "", value)
value = float(value)

if isinstance(value, str) and len(value) < 1:
return STATE_UNKNOWN

return value
except KeyError:
Expand Down

0 comments on commit 0931c36

Please sign in to comment.