Skip to content

Commit

Permalink
Merge pull request #62 from monty68/dev_v2
Browse files Browse the repository at this point in the history
v2.2.5
  • Loading branch information
monty68 authored Feb 20, 2024
2 parents 0d0381c + 0335ab7 commit 9888df5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![GitHub Activity][commits-shield]][commits]
[![License][license-shield]][license]

# ![HA][ha-logo] UniLED v2.2.0 - The Universal Light Controller
# ![HA][ha-logo] UniLED v2.2.5 - The Universal Light Controller

### UniLED supports the following range of BLE LED controllers:

Expand Down
16 changes: 9 additions & 7 deletions custom_components/uniled/lib/ble/banlanx2.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def parse_notifications(
{
ATTR_UL_DEVICE_FORCE_REFRESH: True,
ATTR_UL_POWER: data[0] == 1,
ATTR_HA_SUPPORTED_COLOR_MODES: [COLOR_MODE_BRIGHTNESS],
ATTR_HA_SUPPORTED_COLOR_MODES: {COLOR_MODE_BRIGHTNESS},
ATTR_HA_COLOR_MODE: COLOR_MODE_BRIGHTNESS,
ATTR_UL_CHIP_ORDER: self.chip_order_name(
UNILED_CHIP_ORDER_RGBW
Expand Down Expand Up @@ -465,10 +465,10 @@ def parse_notifications(
if self.colors == 4:
device.master.set(ATTR_HA_WHITE, cold)
device.master.set(
ATTR_HA_SUPPORTED_COLOR_MODES, [COLOR_MODE_RGB, COLOR_MODE_WHITE]
ATTR_HA_SUPPORTED_COLOR_MODES, {COLOR_MODE_RGB, COLOR_MODE_WHITE}
)
else:
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, [COLOR_MODE_RGB])
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, {COLOR_MODE_RGB})

if effect in BANLANX2_EFFECTS_SOUND:
device.master.set(ATTR_UL_EFFECT_TYPE, UNILED_EFFECT_TYPE_SOUND)
Expand All @@ -477,7 +477,7 @@ def parse_notifications(
ATTR_UL_AUDIO_INPUT,
self.str_if_key_in(input, BANLANX2_AUDIO_INPUTS, UNILED_UNKNOWN),
)
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, [COLOR_MODE_ONOFF])
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, {COLOR_MODE_ONOFF})
device.master.set(ATTR_HA_COLOR_MODE, COLOR_MODE_ONOFF)
device.master.set(ATTR_UL_COLOR_LEVEL, level)
device.master.set(ATTR_HA_BRIGHTNESS, None)
Expand All @@ -486,7 +486,7 @@ def parse_notifications(
if effect == BANLANX2_EFFECT_WHITE:
device.master.set(
ATTR_HA_SUPPORTED_COLOR_MODES,
[COLOR_MODE_RGB, COLOR_MODE_WHITE],
{COLOR_MODE_RGB, COLOR_MODE_WHITE},
)
device.master.set(ATTR_HA_COLOR_MODE, COLOR_MODE_WHITE)
device.master.set(ATTR_HA_BRIGHTNESS, cold)
Expand All @@ -505,7 +505,7 @@ def parse_notifications(
device.master.set(ATTR_UL_EFFECT_LENGTH, length)
device.master.set(ATTR_UL_EFFECT_TYPE, UNILED_EFFECT_TYPE_DYNAMIC)
elif mode == BANLANX2_LIGHT_MODE_AUTO_SOUND:
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, [COLOR_MODE_ONOFF])
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, {COLOR_MODE_ONOFF})
device.master.set(ATTR_HA_COLOR_MODE, COLOR_MODE_ONOFF)
device.master.set(ATTR_UL_COLOR_LEVEL, level)
device.master.set(ATTR_HA_BRIGHTNESS, None)
Expand Down Expand Up @@ -707,7 +707,9 @@ def fetch_chip_order_list(
id=0x617E,
name="SP617E",
info="SPI RGB(W) (Music) Controller",
data=b"\x17\x10",
# Fix: Issue #57 - Second byte can be different so only check first byte
# data=b"\x17\x10",
data=b"\x17",
colors=4,
intmic=True,
)
Expand Down
12 changes: 6 additions & 6 deletions custom_components/uniled/lib/ble/banlanx3.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def parse_notifications(
{
ATTR_UL_DEVICE_FORCE_REFRESH: True,
ATTR_UL_POWER: data[0] == 1,
ATTR_HA_SUPPORTED_COLOR_MODES: [COLOR_MODE_BRIGHTNESS],
ATTR_HA_SUPPORTED_COLOR_MODES: {COLOR_MODE_BRIGHTNESS},
ATTR_HA_COLOR_MODE: COLOR_MODE_BRIGHTNESS,
ATTR_UL_CHIP_ORDER: self.chip_order_name(
UNILED_CHIP_ORDER_RGBW
Expand Down Expand Up @@ -315,10 +315,10 @@ def parse_notifications(
if self.colors == 4:
device.master.set(ATTR_HA_WHITE, cold)
device.master.set(
ATTR_HA_SUPPORTED_COLOR_MODES, [COLOR_MODE_RGB, COLOR_MODE_WHITE]
ATTR_HA_SUPPORTED_COLOR_MODES, {COLOR_MODE_RGB, COLOR_MODE_WHITE}
)
else:
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, [COLOR_MODE_RGB])
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, {COLOR_MODE_RGB})

if effect >= BANLANX3_EFFECT_SOUND and effect < BANLANX3_EFFECT_WHITE:
device.master.set(ATTR_UL_EFFECT_TYPE, UNILED_EFFECT_TYPE_SOUND)
Expand All @@ -327,7 +327,7 @@ def parse_notifications(
ATTR_UL_AUDIO_INPUT,
self.str_if_key_in(input, BANLANX3_AUDIO_INPUTS, UNILED_UNKNOWN),
)
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, [COLOR_MODE_ONOFF])
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, {COLOR_MODE_ONOFF})
device.master.set(ATTR_HA_COLOR_MODE, COLOR_MODE_ONOFF)
device.master.set(ATTR_UL_COLOR_LEVEL, level)
device.master.set(ATTR_HA_BRIGHTNESS, None)
Expand All @@ -336,7 +336,7 @@ def parse_notifications(
if effect == BANLANX3_EFFECT_WHITE:
device.master.set(
ATTR_HA_SUPPORTED_COLOR_MODES,
[COLOR_MODE_RGB, COLOR_MODE_WHITE],
{COLOR_MODE_RGB, COLOR_MODE_WHITE},
)
device.master.set(ATTR_HA_COLOR_MODE, COLOR_MODE_WHITE)
device.master.set(ATTR_HA_BRIGHTNESS, cold)
Expand All @@ -355,7 +355,7 @@ def parse_notifications(
elif mode == BANLANX3_LIGHT_MODE_AUTO_SOUND:
device.master.set(ATTR_UL_EFFECT_TYPE, UNILED_EFFECT_TYPE_SOUND)
device.master.set(ATTR_UL_SENSITIVITY, gain)
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, [COLOR_MODE_ONOFF])
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, {COLOR_MODE_ONOFF})
device.master.set(ATTR_HA_COLOR_MODE, COLOR_MODE_ONOFF)
device.master.set(ATTR_UL_COLOR_LEVEL, level)
device.master.set(ATTR_HA_BRIGHTNESS, None)
Expand Down
10 changes: 5 additions & 5 deletions custom_components/uniled/lib/ble/banlanx_6xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,21 +1067,21 @@ def parse_notifications(
device.master.set(ATTR_HA_RGBW_COLOR, (data[37], data[38], data[39], white_level))
elif cfg.hue or cfg.cct or cfg.white:
white_mode = COLOR_MODE_BRIGHTNESS
supported_color_modes = []
supported_color_modes = set()

if cfg.hue:
device.master.set(ATTR_HA_RGB_COLOR, (data[37], data[38], data[39]))
supported_color_modes.append(COLOR_MODE_RGB)
supported_color_modes.add(COLOR_MODE_RGB)
if cfg.cct:
device.master.set(ATTR_UL_CCT_COLOR, (data[40], data[41], white_level, None))
white_mode = COLOR_MODE_COLOR_TEMP
supported_color_modes.append(white_mode)
supported_color_modes.add(white_mode)
elif cfg.white and cfg.hue:
device.master.set(ATTR_HA_WHITE, white_level)
white_mode = COLOR_MODE_WHITE
supported_color_modes.append(white_mode)
supported_color_modes.add(white_mode)
else:
supported_color_modes = [white_mode]
supported_color_modes = set(white_mode)
device.master.set(ATTR_HA_SUPPORTED_COLOR_MODES, supported_color_modes)
device.master.set(ATTR_HA_COLOR_MODE,
COLOR_MODE_RGB
Expand Down
10 changes: 9 additions & 1 deletion custom_components/uniled/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,15 @@ def color_mode(self) -> ColorMode | str | None:

@property
def supported_color_modes(self) -> set[ColorMode] | set[str] | None:
"""Flag supported color modes."""
"""Supported color modes."""
modes = self.__supported_color_modes
if not isinstance(modes, set):
_LOGGER.warning("%s: Modes: %s is not a set!", self.device.name, modes)
return modes

@property
def __supported_color_modes(self) -> set[ColorMode] | set[str] | None:
"""Supported color modes."""
if self.channel.has(ATTR_SUPPORTED_COLOR_MODES):
return self.channel.get(ATTR_SUPPORTED_COLOR_MODES, {ColorMode.ONOFF})
elif self.channel.has(ATTR_RGBWW_COLOR):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/uniled/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"pycryptodome>=3.17",
"cryptography"
],
"version": "2.2.4"
"version": "2.2.5"
}
2 changes: 1 addition & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![GitHub Activity][commits-shield]][commits]
[![License][license-shield]][license]

# UniLED v2.2.0 - The Universal Light Controller
# UniLED v2.2.5 - The Universal Light Controller

### UniLED supports the following range of BLE LED controllers:

Expand Down

0 comments on commit 9888df5

Please sign in to comment.