Simplify mac address handling (#162)

This commit is contained in:
Teemu R 2021-05-12 15:07:53 +02:00 committed by GitHub
parent 28a902c485
commit c7a47ea1bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.