Skip to content

Commit

Permalink
Merge pull request #58 from dmamontov/dev
Browse files Browse the repository at this point in the history
Mass fix
  • Loading branch information
dmamontov authored Apr 29, 2022
2 parents 5ef93c2 + 08e0a47 commit 28d1517
Show file tree
Hide file tree
Showing 45 changed files with 39,434 additions and 32,438 deletions.
31,725 changes: 31,725 additions & 0 deletions custom_components/miwifi/const.py

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions custom_components/miwifi/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@
ATTR_TRACKER_OPTIONAL_MAC,
)
from .enum import Connection
from .helper import generate_entity_id, parse_last_activity, pretty_size
from .helper import (
generate_entity_id,
parse_last_activity,
pretty_size,
detect_manufacturer,
)
from .updater import LuciUpdater

ATTR_CHANGES: Final = [
Expand Down Expand Up @@ -204,7 +209,7 @@ def manufacturer(self) -> str | None:
:return str | None: Manufacturer
"""

return self._updater.manufacturer(self.mac_address)
return detect_manufacturer(self.mac_address)

@property
def ip_address(self) -> str | None:
Expand Down
17 changes: 16 additions & 1 deletion custom_components/miwifi/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from homeassistant.util import slugify
from httpx import codes

from .const import DOMAIN, STORAGE_VERSION, DEFAULT_TIMEOUT
from .const import DOMAIN, STORAGE_VERSION, DEFAULT_TIMEOUT, MANUFACTURERS
from .updater import LuciUpdater


Expand Down Expand Up @@ -124,3 +124,18 @@ def pretty_size(speed: float) -> str:
_p = math.pow(1024, _i)

return f"{round(speed / _p, 2)} {_unit[_i]}"


def detect_manufacturer(mac: str | None) -> str | None:
"""Get manufacturer by mac address
:param mac: str | None: Mac address
:return str | None: Manufacturer
"""

if mac is None:
return None

identifier: str = mac.replace(":", "").upper()[0:6]

return MANUFACTURERS[identifier] if identifier in MANUFACTURERS else None
2 changes: 1 addition & 1 deletion custom_components/miwifi/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "miwifi",
"name": "MiWiFi",
"version": "2.5.4",
"version": "2.6.0",
"documentation": "https://github.com/dmamontov/hass-miwifi/blob/main/README.md",
"issue_tracker": "https://github.com/dmamontov/hass-miwifi/issues",
"config_flow": true,
Expand Down
Loading

0 comments on commit 28d1517

Please sign in to comment.