mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 11:43:34 +00:00
Simplify mac address handling (#162)
This commit is contained in:
parent
28a902c485
commit
c7a47ea1bf
@ -411,16 +411,16 @@ class SmartDevice:
|
|||||||
"""
|
"""
|
||||||
sys_info = self.sys_info
|
sys_info = self.sys_info
|
||||||
|
|
||||||
if "mac" in sys_info:
|
mac = sys_info.get("mac", sys_info.get("mic_mac"))
|
||||||
return str(sys_info["mac"])
|
if not mac:
|
||||||
elif "mic_mac" in sys_info:
|
raise SmartDeviceException(
|
||||||
return ":".join(
|
"Unknown mac, please submit a bug report with sys_info output."
|
||||||
format(s, "02x") for s in bytes.fromhex(sys_info["mic_mac"])
|
|
||||||
)
|
)
|
||||||
|
|
||||||
raise SmartDeviceException(
|
if ":" not in mac:
|
||||||
"Unknown mac, please submit a bug report with sys_info output."
|
mac = ":".join(format(s, "02x") for s in bytes.fromhex(mac))
|
||||||
)
|
|
||||||
|
return mac
|
||||||
|
|
||||||
async def set_mac(self, mac):
|
async def set_mac(self, mac):
|
||||||
"""Set the mac address.
|
"""Set the mac address.
|
||||||
|
Loading…
Reference in New Issue
Block a user