mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Add translations to Hue effects (#138990)
* Add translations to Hue effects * Add translations to Hue effects * Add more effects * Fix * Trigger build
This commit is contained in:
parent
a2f92b1e28
commit
2cbe8a4a14
@ -102,6 +102,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"light": {
|
||||||
|
"hue_light": {
|
||||||
|
"state_attributes": {
|
||||||
|
"effect": {
|
||||||
|
"state": {
|
||||||
|
"candle": "Candle",
|
||||||
|
"sparkle": "Sparkle",
|
||||||
|
"glisten": "Glisten",
|
||||||
|
"sunrise": "Sunrise",
|
||||||
|
"sunset": "Sunset",
|
||||||
|
"fire": "Fire",
|
||||||
|
"prism": "Prism",
|
||||||
|
"opal": "Opal",
|
||||||
|
"underwater": "Underwater",
|
||||||
|
"cosmos": "Cosmos",
|
||||||
|
"sunbeam": "Sunbeam",
|
||||||
|
"enchant": "Enchant"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
"zigbee_connectivity": {
|
"zigbee_connectivity": {
|
||||||
"name": "Zigbee connectivity",
|
"name": "Zigbee connectivity",
|
||||||
|
@ -18,6 +18,7 @@ from homeassistant.components.light import (
|
|||||||
ATTR_FLASH,
|
ATTR_FLASH,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
ATTR_XY_COLOR,
|
ATTR_XY_COLOR,
|
||||||
|
EFFECT_OFF,
|
||||||
FLASH_SHORT,
|
FLASH_SHORT,
|
||||||
ColorMode,
|
ColorMode,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
@ -39,7 +40,6 @@ from .helpers import (
|
|||||||
normalize_hue_transition,
|
normalize_hue_transition,
|
||||||
)
|
)
|
||||||
|
|
||||||
EFFECT_NONE = "None"
|
|
||||||
FALLBACK_MIN_KELVIN = 6500
|
FALLBACK_MIN_KELVIN = 6500
|
||||||
FALLBACK_MAX_KELVIN = 2000
|
FALLBACK_MAX_KELVIN = 2000
|
||||||
FALLBACK_KELVIN = 5800 # halfway
|
FALLBACK_KELVIN = 5800 # halfway
|
||||||
@ -75,7 +75,7 @@ class HueLight(HueBaseEntity, LightEntity):
|
|||||||
|
|
||||||
_fixed_color_mode: ColorMode | None = None
|
_fixed_color_mode: ColorMode | None = None
|
||||||
entity_description = LightEntityDescription(
|
entity_description = LightEntityDescription(
|
||||||
key="hue_light", has_entity_name=True, name=None
|
key="hue_light", translation_key="hue_light", has_entity_name=True, name=None
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -118,7 +118,7 @@ class HueLight(HueBaseEntity, LightEntity):
|
|||||||
if x != TimedEffectStatus.NO_EFFECT
|
if x != TimedEffectStatus.NO_EFFECT
|
||||||
]
|
]
|
||||||
if len(self._attr_effect_list) > 0:
|
if len(self._attr_effect_list) > 0:
|
||||||
self._attr_effect_list.insert(0, EFFECT_NONE)
|
self._attr_effect_list.insert(0, EFFECT_OFF)
|
||||||
self._attr_supported_features |= LightEntityFeature.EFFECT
|
self._attr_supported_features |= LightEntityFeature.EFFECT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -211,7 +211,7 @@ class HueLight(HueBaseEntity, LightEntity):
|
|||||||
if timed_effects := self.resource.timed_effects:
|
if timed_effects := self.resource.timed_effects:
|
||||||
if timed_effects.status != TimedEffectStatus.NO_EFFECT:
|
if timed_effects.status != TimedEffectStatus.NO_EFFECT:
|
||||||
return timed_effects.status.value
|
return timed_effects.status.value
|
||||||
return EFFECT_NONE
|
return EFFECT_OFF
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
@ -233,12 +233,12 @@ class HueLight(HueBaseEntity, LightEntity):
|
|||||||
self._color_temp_active = color_temp is not None
|
self._color_temp_active = color_temp is not None
|
||||||
flash = kwargs.get(ATTR_FLASH)
|
flash = kwargs.get(ATTR_FLASH)
|
||||||
effect = effect_str = kwargs.get(ATTR_EFFECT)
|
effect = effect_str = kwargs.get(ATTR_EFFECT)
|
||||||
if effect_str in (EFFECT_NONE, EFFECT_NONE.lower()):
|
if effect_str == EFFECT_OFF:
|
||||||
# ignore effect if set to "None" and we have no effect active
|
# ignore effect if set to "off" and we have no effect active
|
||||||
# the special effect "None" is only used to stop an active effect
|
# the special effect "off" is only used to stop an active effect
|
||||||
# but sending it while no effect is active can actually result in issues
|
# but sending it while no effect is active can actually result in issues
|
||||||
# https://github.com/home-assistant/core/issues/122165
|
# https://github.com/home-assistant/core/issues/122165
|
||||||
effect = None if self.effect == EFFECT_NONE else EffectStatus.NO_EFFECT
|
effect = None if self.effect == EFFECT_OFF else EffectStatus.NO_EFFECT
|
||||||
elif effect_str is not None:
|
elif effect_str is not None:
|
||||||
# work out if we got a regular effect or timed effect
|
# work out if we got a regular effect or timed effect
|
||||||
effect = EffectStatus(effect_str)
|
effect = EffectStatus(effect_str)
|
||||||
|
@ -42,8 +42,8 @@ async def test_lights(
|
|||||||
assert light_1.attributes["min_mireds"] == 153
|
assert light_1.attributes["min_mireds"] == 153
|
||||||
assert light_1.attributes["max_mireds"] == 500
|
assert light_1.attributes["max_mireds"] == 500
|
||||||
assert light_1.attributes["dynamics"] == "dynamic_palette"
|
assert light_1.attributes["dynamics"] == "dynamic_palette"
|
||||||
assert light_1.attributes["effect_list"] == ["None", "candle", "fire"]
|
assert light_1.attributes["effect_list"] == ["off", "candle", "fire"]
|
||||||
assert light_1.attributes["effect"] == "None"
|
assert light_1.attributes["effect"] == "off"
|
||||||
|
|
||||||
# test light which supports color temperature only
|
# test light which supports color temperature only
|
||||||
light_2 = hass.states.get("light.hue_light_with_color_temperature_only")
|
light_2 = hass.states.get("light.hue_light_with_color_temperature_only")
|
||||||
@ -57,7 +57,7 @@ async def test_lights(
|
|||||||
assert light_2.attributes["min_mireds"] == 153
|
assert light_2.attributes["min_mireds"] == 153
|
||||||
assert light_2.attributes["max_mireds"] == 454
|
assert light_2.attributes["max_mireds"] == 454
|
||||||
assert light_2.attributes["dynamics"] == "none"
|
assert light_2.attributes["dynamics"] == "none"
|
||||||
assert light_2.attributes["effect_list"] == ["None", "candle", "sunrise"]
|
assert light_2.attributes["effect_list"] == ["off", "candle", "sunrise"]
|
||||||
|
|
||||||
# test light which supports color only
|
# test light which supports color only
|
||||||
light_3 = hass.states.get("light.hue_light_with_color_only")
|
light_3 = hass.states.get("light.hue_light_with_color_only")
|
||||||
@ -201,7 +201,7 @@ async def test_light_turn_on_service(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"light",
|
"light",
|
||||||
"turn_on",
|
"turn_on",
|
||||||
{"entity_id": test_light_id, "effect": "None"},
|
{"entity_id": test_light_id, "effect": "off"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(mock_bridge_v2.mock_requests) == 8
|
assert len(mock_bridge_v2.mock_requests) == 8
|
||||||
@ -216,14 +216,14 @@ async def test_light_turn_on_service(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
test_light = hass.states.get(test_light_id)
|
test_light = hass.states.get(test_light_id)
|
||||||
assert test_light is not None
|
assert test_light is not None
|
||||||
assert test_light.attributes["effect"] == "None"
|
assert test_light.attributes["effect"] == "off"
|
||||||
|
|
||||||
# test turn on with useless effect
|
# test turn on with useless effect
|
||||||
# it should send a effect in the request if the device has no effect active
|
# it should send a effect in the request if the device has no effect active
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"light",
|
"light",
|
||||||
"turn_on",
|
"turn_on",
|
||||||
{"entity_id": test_light_id, "effect": "None"},
|
{"entity_id": test_light_id, "effect": "off"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert len(mock_bridge_v2.mock_requests) == 9
|
assert len(mock_bridge_v2.mock_requests) == 9
|
||||||
|
Loading…
x
Reference in New Issue
Block a user