Skip to content

Commit

Permalink
Recognize more SSDP friendly names as "ours"
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Nov 6, 2022
1 parent fc472eb commit 4bd2e28
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions homeassistant/components/huawei_lte/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from collections.abc import Mapping
import logging
import re
from typing import TYPE_CHECKING, Any
from urllib.parse import urlparse

Expand Down Expand Up @@ -232,10 +233,13 @@ async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowRes
self._abort_if_unique_id_configured()

# Attempt to distinguish from other non-LTE Huawei router devices, at least
# some ones we are interested in have "Mobile Wi-Fi" friendlyName.
if (
"mobile"
not in discovery_info.upnp.get(ssdp.ATTR_UPNP_FRIENDLY_NAME, "").lower()
# some of the ones we are interested in include friendlyNames like
# "Mobile Wi-Fi", "4G CPE 3", and "华为4G路由 B525". (The last one is
# an example why there are no word boundary markers around the regex.)
if not re.search(
r"[45]G|LTE|Mobile",
discovery_info.upnp.get(ssdp.ATTR_UPNP_FRIENDLY_NAME, ""),
re.IGNORECASE,
):
return self.async_abort(reason="not_huawei_lte")

Expand Down

0 comments on commit 4bd2e28

Please sign in to comment.