Filter out HTML greater/less than entities from huawei_lte sensor values (#117209)
This commit is contained in:
parent
3a8bdfbfdf
commit
a27cc24da2
2 changed files with 3 additions and 1 deletions
|
@ -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"))
|
||||
|
|
|
@ -15,6 +15,8 @@ from homeassistant.const import (
|
|||
("-71 dBm", (-71, SIGNAL_STRENGTH_DECIBELS_MILLIWATT)),
|
||||
("15dB", (15, SIGNAL_STRENGTH_DECIBELS)),
|
||||
(">=-51dBm", (-51, SIGNAL_STRENGTH_DECIBELS_MILLIWATT)),
|
||||
("<-20dB", (-20, SIGNAL_STRENGTH_DECIBELS)),
|
||||
(">=30dB", (30, SIGNAL_STRENGTH_DECIBELS)),
|
||||
],
|
||||
)
|
||||
def test_format_default(value, expected) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue