mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Refactor light significant change to use kelvin attribute (#132853)
This commit is contained in:
parent
f0f0b4b8fa
commit
4ff41ed2f8
@ -7,7 +7,7 @@ from typing import Any
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.significant_change import check_absolute_change
|
||||
|
||||
from . import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_HS_COLOR
|
||||
from . import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP_KELVIN, ATTR_EFFECT, ATTR_HS_COLOR
|
||||
|
||||
|
||||
@callback
|
||||
@ -44,10 +44,10 @@ def async_check_significant_change(
|
||||
return True
|
||||
|
||||
if check_absolute_change(
|
||||
# Default range 153..500
|
||||
old_attrs.get(ATTR_COLOR_TEMP),
|
||||
new_attrs.get(ATTR_COLOR_TEMP),
|
||||
5,
|
||||
# Default range 2000..6500
|
||||
old_attrs.get(ATTR_COLOR_TEMP_KELVIN),
|
||||
new_attrs.get(ATTR_COLOR_TEMP_KELVIN),
|
||||
50,
|
||||
):
|
||||
return True
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP,
|
||||
ATTR_COLOR_TEMP_KELVIN,
|
||||
ATTR_EFFECT,
|
||||
ATTR_HS_COLOR,
|
||||
)
|
||||
@ -26,10 +26,10 @@ async def test_significant_change() -> None:
|
||||
|
||||
# Color temp
|
||||
assert not async_check_significant_change(
|
||||
None, "on", {ATTR_COLOR_TEMP: 60}, "on", {ATTR_COLOR_TEMP: 64}
|
||||
None, "on", {ATTR_COLOR_TEMP_KELVIN: 2000}, "on", {ATTR_COLOR_TEMP_KELVIN: 2049}
|
||||
)
|
||||
assert async_check_significant_change(
|
||||
None, "on", {ATTR_COLOR_TEMP: 60}, "on", {ATTR_COLOR_TEMP: 65}
|
||||
None, "on", {ATTR_COLOR_TEMP_KELVIN: 2000}, "on", {ATTR_COLOR_TEMP_KELVIN: 2050}
|
||||
)
|
||||
|
||||
# Effect
|
||||
|
Loading…
x
Reference in New Issue
Block a user