-
-
Notifications
You must be signed in to change notification settings - Fork 817
Fix LightEntity AttributeError: remove deprecated _attr_color_temp and mireds #2794
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
Merged
al-one
merged 2 commits into
al-one:master
from
smkrv:fix/light-remove-deprecated-color-temp-mireds
Mar 9, 2026
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,8 +103,11 @@ def on_init(self): | |
| self._attr_max_color_temp_kelvin = prop.range_max() | ||
| self._attr_names[ATTR_COLOR_TEMP_KELVIN] = attr | ||
| else: | ||
| self._attr_min_mireds = prop.range_min() | ||
| self._attr_max_mireds = prop.range_max() | ||
| # Convert mireds range to kelvin (mireds min -> kelvin max) | ||
| mireds_min = prop.range_min() | ||
| mireds_max = prop.range_max() | ||
| self._attr_min_color_temp_kelvin = int(1000000 / mireds_max) if mireds_max else 2000 | ||
| self._attr_max_color_temp_kelvin = int(1000000 / mireds_min) if mireds_min else 6500 | ||
| self._attr_names[ATTR_COLOR_TEMP] = attr | ||
| elif prop.in_list(['color', color_property]) or isinstance(conv, MiotRgbColorConv): | ||
| self._attr_names[ATTR_RGB_COLOR] = attr | ||
|
|
@@ -120,7 +123,7 @@ def get_state(self) -> dict: | |
| return { | ||
| self.attr: self._attr_is_on, | ||
| ATTR_BRIGHTNESS: self._attr_brightness, | ||
| ATTR_COLOR_TEMP: self._attr_color_temp, | ||
| ATTR_COLOR_TEMP_KELVIN: self._attr_color_temp_kelvin, | ||
| } | ||
|
|
||
| def set_state(self, data: dict): | ||
|
|
@@ -137,8 +140,9 @@ def set_state(self, data: dict): | |
| self._attr_color_temp_kelvin = val | ||
| self._attr_color_mode = ColorMode.COLOR_TEMP | ||
| elif (val := data.get(self._attr_names.get(ATTR_COLOR_TEMP))) is not None: | ||
| if val != self._attr_color_temp: | ||
| self._attr_color_temp = val | ||
| kelvin = int(1000000 / val) if val else None | ||
|
||
| if kelvin and kelvin != self._attr_color_temp_kelvin: | ||
| self._attr_color_temp_kelvin = kelvin | ||
| self._attr_color_mode = ColorMode.COLOR_TEMP | ||
| if (val := data.get(self._attr_names.get(ATTR_RGB_COLOR))) is not None: | ||
| if val != self._attr_rgb_color: | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability of large numbers, you can use underscores as a visual separator. This would make the conversion factor
1000000easier to read.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks! Applied
1_000_000across all three occurrences in 53ee93d.