Skip to content

Commit

Permalink
Filter out HTML greater/less than entities from huawei_lte sensor val…
Browse files Browse the repository at this point in the history
…ues (#117209)
  • Loading branch information
scop authored May 18, 2024
1 parent 3a8bdfb commit a27cc24
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion homeassistant/components/huawei_lte/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def format_default(value: StateType) -> tuple[StateType, str | None]:
if value is not None:
# Clean up value and infer unit, e.g. -71dBm, 15 dB
if match := re.match(
r"([>=<]*)(?P<value>.+?)\s*(?P<unit>[a-zA-Z]+)\s*$", str(value)
r"((&[gl]t;|[><])=?)?(?P<value>.+?)\s*(?P<unit>[a-zA-Z]+)\s*$", str(value)
):
try:
value = float(match.group("value"))
Expand Down
2 changes: 2 additions & 0 deletions tests/components/huawei_lte/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
("-71 dBm", (-71, SIGNAL_STRENGTH_DECIBELS_MILLIWATT)),
("15dB", (15, SIGNAL_STRENGTH_DECIBELS)),
(">=-51dBm", (-51, SIGNAL_STRENGTH_DECIBELS_MILLIWATT)),
("&lt;-20dB", (-20, SIGNAL_STRENGTH_DECIBELS)),
("&gt;=30dB", (30, SIGNAL_STRENGTH_DECIBELS)),
],
)
def test_format_default(value, expected) -> None:
Expand Down

0 comments on commit a27cc24

Please sign in to comment.