Repository: home-assistant/core
File: homeassistant/components/ads/light.py (Python)

Code before:
        """Initialize AdsLight entity."""
        super().__init__(ads_hub, name, ads_var_enable)
        self._state_dict[STATE_KEY_BRIGHTNESS] = None
        self._state_dict[STATE_KEY_COLOR_TEMP_KELVIN] = None
        self._ads_var_brightness = ads_var_brightness
        self._ads_var_color_temp_kelvin = ads_var_color_temp_kelvin
        self._min_color_temp_kelvin = min_color_temp_kelvin
        self._max_color_temp_kelvin = max_color_temp_kelvin

        # Determine supported color modes
        supported_modes = {ColorMode.ONOFF}
        if ads_var_brightness is not None:
            supported_modes.add(ColorMode.BRIGHTNESS)
        if ads_var_color_temp_kelvin is not None:
            supported_modes.add(ColorMode.COLOR_TEMP)

        self._attr_supported_color_modes = supported_modes
        self._attr_color_mode = next(iter(supported_modes))

        # Set color temperature range (static config values take precedence over defaults)
        self._attr_min_color_temp_kelvin = (
            min_color_temp_kelvin if min_color_temp_kelvin is not None else 2000
        )
        self._attr_max_color_temp_kelvin = (
            max_color_temp_kelvin if max_color_temp_kelvin is not None else 6500
        )

    async def async_added_to_hass(self) -> None:
        """Register device notification."""
        await self.async_initialize_device(self._ads_var, pyads.PLCTYPE_BOOL)

        if self._ads_var_brightness is not None:
            await self.async_initialize_device(
                self._ads_var_brightness,
                pyads.PLCTYPE_UINT,
                STATE_KEY_BRIGHTNESS,
            )

        if self._ads_var_color_temp_kelvin is not None:
            await self.async_initialize_device(
                self._ads_var_color_temp_kelvin,
                pyads.PLCTYPE_UINT,
                STATE_KEY_COLOR_TEMP_KELVIN,
            )

    @property
    def brightness(self) -> int | None:
        """Return the brightness of the light (0..255)."""
        return self._state_dict[STATE_KEY_BRIGHTNESS]

    @property

Review comment (suggestion):
Is there any reason to use 2000 and 6500 as the default min and max color temp respectively?
If there isn't any specific reason, I think I would be better if we use `DEFAULT_MIN_KELVIN` and `DEFAULT_MAX_KELVIN` from `homeassistant.components.light`

Code after:
        max_color_temp_kelvin: int | None,
        name: str,
    ) -> None:
        """Initialize AdsLight entity."""
        super().__init__(ads_hub, name, ads_var_enable)
        self._state_dict[STATE_KEY_BRIGHTNESS] = None
        self._state_dict[STATE_KEY_COLOR_TEMP_KELVIN] = None
        self._ads_var_brightness = ads_var_brightness
        self._ads_var_color_temp_kelvin = ads_var_color_temp_kelvin

        # Determine supported color modes
        color_modes = {ColorMode.ONOFF}
        if ads_var_brightness is not None:
            color_modes.add(ColorMode.BRIGHTNESS)
        if ads_var_color_temp_kelvin is not None:
            color_modes.add(ColorMode.COLOR_TEMP)

        self._attr_supported_color_modes = filter_supported_color_modes(color_modes)
        self._attr_color_mode = next(iter(self._attr_supported_color_modes))

        # Set color temperature range (static config values take precedence over defaults)
        if ads_var_color_temp_kelvin is not None:
            self._attr_min_color_temp_kelvin = (
                min_color_temp_kelvin
                if min_color_temp_kelvin is not None
                else DEFAULT_MIN_KELVIN
            )
            self._attr_max_color_temp_kelvin = (
                max_color_temp_kelvin
                if max_color_temp_kelvin is not None
                else DEFAULT_MAX_KELVIN
            )

    async def async_added_to_hass(self) -> None:
        """Register device notification."""
        await self.async_initialize_device(self._ads_var, pyads.PLCTYPE_BOOL)

        if self._ads_var_brightness is not None:
            await self.async_initialize_device(
                self._ads_var_brightness,
                pyads.PLCTYPE_UINT,
                STATE_KEY_BRIGHTNESS,
            )

        if self._ads_var_color_temp_kelvin is not None:
            await self.async_initialize_device(
                self._ads_var_color_temp_kelvin,
                pyads.PLCTYPE_UINT,
                STATE_KEY_COLOR_TEMP_KELVIN,
            )