Skip to content

Commit dfbf20e

Browse files
authored
HA 2025.3 deprecated warning fix (#25)
* fix 2025.3 warning message * version bump
1 parent 45e6e42 commit dfbf20e

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

custom_components/lednetwf_ble/lednetwf.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def __init__(self, mac, hass, data={}, options={}) -> None:
165165
self._min_color_temp_kelvin = 2700
166166
self._max_color_temp_kelvin = 6500
167167
self._model = self._detect_model(service_info['manufacturer_data'])
168-
self._color_mode = ColorMode.HS if self._model == RING_LIGHT_MODEL else ColorMode.RGB #COlorMode.RGB IS GETTING DEPRECATED, CHANGE !!!!!!!!!!
168+
self._color_mode = ColorMode.HS if self._model == RING_LIGHT_MODEL else ColorMode.RGB
169169
self._write_uuid = None
170170
self._read_uuid = None
171171
self._led_count = options.get(CONF_LEDCOUNT, None)
@@ -195,7 +195,8 @@ def _detect_model(self, manu_data):
195195
formatted_str = ' '.join(formatted)
196196
self.log(f"DM:\t\t Manu data: {formatted_str}")
197197

198-
self._color_mode = ColorMode.BRIGHTNESS ## ColorMode.Brigtness is getting deprecated, change !!!!!!!!!!!
198+
self._color_mode = ColorMode.UNKNOWN
199+
# 2025.3 Setting color mode as UNKNOWN will avoid throwing error on unsupported color mode
199200

200201
self._fw_major = manu_data_data[0]
201202
self._fw_minor = f'{manu_data_data[8]:02X}{manu_data_data[9]:02X}.{manu_data_data[10]:02X}'
@@ -206,9 +207,6 @@ def _detect_model(self, manu_data):
206207
# Colour mode (RGB & Whites) and "Static" effects
207208
if manu_data_data[16] == 0xf0:
208209
# RGB Mode
209-
210-
### ColorMode.RGB is getting deprecated, change !!!!!!!!!!!!
211-
212210
r,g,b = manu_data_data[18], manu_data_data[19], manu_data_data[20]
213211
if self._fw_major == RING_LIGHT_MODEL:
214212
self._rgb_color = (r,g,b)

custom_components/lednetwf_ble/light.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ def __init__(
4444
) -> None:
4545
self._instance = lednetwfinstance
4646
self._entry_id = entry_id
47+
# 2025.3 ColorMode.BRIGHTNESS should not be specified with other combination of supported color modes, as it will throw an error, but is is supported
48+
# when lights are rendering an effect automatically
49+
# https://developers.home-assistant.io/docs/core/entity/light/#color-modes
4750
if self._instance._model == RING_LIGHT_MODEL:
48-
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS, ColorMode.COLOR_TEMP, ColorMode.HS}
51+
self._attr_supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS}
4952
self._color_temp_kelvin: self._instance._color_temp_kelvin
5053
else:
51-
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS, ColorMode.RGB}
54+
self._attr_supported_color_modes = {ColorMode.RGB}
5255
self._attr_supported_features = LightEntityFeature.EFFECT
5356
self._attr_name = name
5457
self._attr_unique_id = self._instance.mac
@@ -218,7 +221,14 @@ def light_local_callback(self):
218221
def update_ha_state(self) -> None:
219222
LOGGER.debug("update_ha_state called")
220223
if self.hs_color is None and self.color_temp_kelvin is None and self.rgb_color is None:
221-
self._color_mode = ColorMode.BRIGHTNESS #2024.2 We can use brightness color mode so even when we don't know the state of the light the brightness can be controlled
224+
if self._instance._effect is not None and self._instance._effect is not EFFECT_OFF:
225+
self._color_mode = ColorMode.BRIGHTNESS
226+
#2024.2 We can use brightness color mode so even when we don't know the state of the light the brightness can be controlled
227+
#2025.3 ColorMode.BRIGHTNESS is not considered a valid supported color when on standalone, this gets ignored when
228+
#light is rendering an effect
229+
else:
230+
self._color_mode = ColorMode.UNKNOWN
231+
#2025.3 When not sure of color mode ColorMode.UNKNOWN avoids throwing errors on unsupported combination of color modes
222232
elif self.hs_color is not None:
223233
self._color_mode = ColorMode.HS
224234
elif self.rgb_color is not None:

custom_components/lednetwf_ble/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
"bleak-retry-connector>=1.17.1",
2323
"bleak>=0.17.0"
2424
],
25-
"version": "0.0.10"
25+
"version": "0.0.12"
2626
}

0 commit comments

Comments
 (0)