2022-02-05 15:23:19 +00:00
|
|
|
"""WiZ utils."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
2022-02-05 16:36:44 +00:00
|
|
|
from pywizlight import BulbType
|
2022-02-10 15:08:33 +00:00
|
|
|
from pywizlight.bulblibrary import BulbClass
|
2022-02-05 16:36:44 +00:00
|
|
|
|
2022-02-07 16:44:52 +00:00
|
|
|
from .const import DEFAULT_NAME
|
2022-02-05 16:36:44 +00:00
|
|
|
|
2022-02-05 15:23:19 +00:00
|
|
|
|
|
|
|
def _short_mac(mac: str) -> str:
|
|
|
|
"""Get the short mac address from the full mac."""
|
|
|
|
return mac.replace(":", "").upper()[-6:]
|
2022-02-05 16:36:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
def name_from_bulb_type_and_mac(bulb_type: BulbType, mac: str) -> str:
|
|
|
|
"""Generate a name from bulb_type and mac."""
|
2022-02-10 15:08:33 +00:00
|
|
|
if bulb_type.bulb_type == BulbClass.RGB:
|
|
|
|
if bulb_type.white_channels == 2:
|
|
|
|
description = "RGBWW Tunable"
|
|
|
|
else:
|
|
|
|
description = "RGBW Tunable"
|
|
|
|
else:
|
|
|
|
description = bulb_type.bulb_type.value
|
|
|
|
return f"{DEFAULT_NAME} {description} {_short_mac(mac)}"
|