Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HA 2025.3 deprecated warning fix #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions custom_components/lednetwf_ble/lednetwf.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def __init__(self, mac, hass, data={}, options={}) -> None:
self._min_color_temp_kelvin = 2700
self._max_color_temp_kelvin = 6500
self._model = self._detect_model(service_info['manufacturer_data'])
self._color_mode = ColorMode.HS if self._model == RING_LIGHT_MODEL else ColorMode.RGB #COlorMode.RGB IS GETTING DEPRECATED, CHANGE !!!!!!!!!!
self._color_mode = ColorMode.HS if self._model == RING_LIGHT_MODEL else ColorMode.RGB
self._write_uuid = None
self._read_uuid = None
self._led_count = options.get(CONF_LEDCOUNT, None)
Expand Down Expand Up @@ -195,7 +195,8 @@ def _detect_model(self, manu_data):
formatted_str = ' '.join(formatted)
self.log(f"DM:\t\t Manu data: {formatted_str}")

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

self._fw_major = manu_data_data[0]
self._fw_minor = f'{manu_data_data[8]:02X}{manu_data_data[9]:02X}.{manu_data_data[10]:02X}'
Expand All @@ -206,9 +207,6 @@ def _detect_model(self, manu_data):
# Colour mode (RGB & Whites) and "Static" effects
if manu_data_data[16] == 0xf0:
# RGB Mode

### ColorMode.RGB is getting deprecated, change !!!!!!!!!!!!

r,g,b = manu_data_data[18], manu_data_data[19], manu_data_data[20]
if self._fw_major == RING_LIGHT_MODEL:
self._rgb_color = (r,g,b)
Expand Down
16 changes: 13 additions & 3 deletions custom_components/lednetwf_ble/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ def __init__(
) -> None:
self._instance = lednetwfinstance
self._entry_id = entry_id
# 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
# when lights are rendering an effect automatically
# https://developers.home-assistant.io/docs/core/entity/light/#color-modes
if self._instance._model == RING_LIGHT_MODEL:
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS, ColorMode.COLOR_TEMP, ColorMode.HS}
self._attr_supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS}
self._color_temp_kelvin: self._instance._color_temp_kelvin
else:
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS, ColorMode.RGB}
self._attr_supported_color_modes = {ColorMode.RGB}
self._attr_supported_features = LightEntityFeature.EFFECT
self._attr_name = name
self._attr_unique_id = self._instance.mac
Expand Down Expand Up @@ -218,7 +221,14 @@ def light_local_callback(self):
def update_ha_state(self) -> None:
LOGGER.debug("update_ha_state called")
if self.hs_color is None and self.color_temp_kelvin is None and self.rgb_color is None:
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
if self._instance._effect is not None and self._instance._effect is not EFFECT_OFF:
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
#2025.3 ColorMode.BRIGHTNESS is not considered a valid supported color when on standalone, this gets ignored when
#light is rendering an effect
else:
self._color_mode = ColorMode.UNKNOWN
#2025.3 When not sure of color mode ColorMode.UNKNOWN avoids throwing errors on unsupported combination of color modes
elif self.hs_color is not None:
self._color_mode = ColorMode.HS
elif self.rgb_color is not None:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/lednetwf_ble/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"bleak-retry-connector>=1.17.1",
"bleak>=0.17.0"
],
"version": "0.0.10"
"version": "0.0.11"
}
Loading