Home Assistant Unofficial Reference 2024.12.1
utils.py
Go to the documentation of this file.
1 """WiZ utils."""
2 
3 from __future__ import annotations
4 
5 from pywizlight import BulbType
6 from pywizlight.bulblibrary import BulbClass
7 
8 from .const import DEFAULT_NAME
9 
10 
11 def _short_mac(mac: str) -> str:
12  """Get the short mac address from the full mac."""
13  return mac.replace(":", "").upper()[-6:]
14 
15 
16 def name_from_bulb_type_and_mac(bulb_type: BulbType, mac: str) -> str:
17  """Generate a name from bulb_type and mac."""
18  if bulb_type.bulb_type == BulbClass.RGB:
19  if bulb_type.white_channels == 2:
20  description = "RGBWW Tunable"
21  else:
22  description = "RGBW Tunable"
23  else:
24  description = bulb_type.bulb_type.value
25  return f"{DEFAULT_NAME} {description} {_short_mac(mac)}"
str name_from_bulb_type_and_mac(BulbType bulb_type, str mac)
Definition: utils.py:16