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

Avoid recording additional light attributes #121776

Merged
merged 1 commit into from
Jul 12, 2024
Merged
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
Avoid recording additional light attributes
The following attributes are no longer saved in the database for light entities
because their combinations would quickly fill up the database and they are
never used by Home Assistant core:

- brightness
- color_mode
- color_temp
- color_temp_kelvin
- effect
- hs_color
- rgb_color
- rgbw_color
- rgbww_color
- xy_color

This has no effect on the run time of light entities.
  • Loading branch information
bdraco committed Jul 11, 2024
commit 8b8549e776706cd3438b291d5a47f622cb8e4581
10 changes: 10 additions & 0 deletions homeassistant/components/light/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,16 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
ATTR_MAX_MIREDS,
ATTR_MIN_COLOR_TEMP_KELVIN,
ATTR_MAX_COLOR_TEMP_KELVIN,
ATTR_BRIGHTNESS,
ATTR_COLOR_MODE,
ATTR_COLOR_TEMP,
ATTR_COLOR_TEMP_KELVIN,
ATTR_EFFECT,
ATTR_HS_COLOR,
ATTR_RGB_COLOR,
ATTR_RGBW_COLOR,
ATTR_RGBWW_COLOR,
ATTR_XY_COLOR,
}
)

Expand Down
23 changes: 22 additions & 1 deletion tests/components/light/test_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@

from homeassistant.components import light
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_MODE,
ATTR_COLOR_TEMP,
ATTR_COLOR_TEMP_KELVIN,
ATTR_EFFECT,
ATTR_EFFECT_LIST,
ATTR_HS_COLOR,
ATTR_MAX_COLOR_TEMP_KELVIN,
ATTR_MAX_MIREDS,
ATTR_MIN_COLOR_TEMP_KELVIN,
ATTR_MIN_MIREDS,
ATTR_RGB_COLOR,
ATTR_RGBW_COLOR,
ATTR_RGBWW_COLOR,
ATTR_SUPPORTED_COLOR_MODES,
ATTR_XY_COLOR,
DOMAIN,
)
from homeassistant.components.recorder import Recorder
from homeassistant.components.recorder.history import get_significant_states
Expand Down Expand Up @@ -50,7 +61,7 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
await async_wait_recording_done(hass)

states = await hass.async_add_executor_job(
get_significant_states, hass, now, None, hass.states.async_entity_ids()
get_significant_states, hass, now, None, hass.states.async_entity_ids(DOMAIN)
)
assert len(states) >= 1
for entity_states in states.values():
Expand All @@ -62,3 +73,13 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
assert ATTR_FRIENDLY_NAME in state.attributes
assert ATTR_MAX_COLOR_TEMP_KELVIN not in state.attributes
assert ATTR_MIN_COLOR_TEMP_KELVIN not in state.attributes
assert ATTR_BRIGHTNESS not in state.attributes
assert ATTR_COLOR_MODE not in state.attributes
assert ATTR_COLOR_TEMP not in state.attributes
assert ATTR_COLOR_TEMP_KELVIN not in state.attributes
assert ATTR_EFFECT not in state.attributes
assert ATTR_HS_COLOR not in state.attributes
assert ATTR_RGB_COLOR not in state.attributes
assert ATTR_RGBW_COLOR not in state.attributes
assert ATTR_RGBWW_COLOR not in state.attributes
assert ATTR_XY_COLOR not in state.attributes