Migrate Yeelight to has entity naming (#96836)
This commit is contained in:
parent
0624345322
commit
daa76bbab6
4 changed files with 32 additions and 20 deletions
|
@ -472,11 +472,6 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
|
|||
self._color_temp = kelvin_to_mired(int(temp_in_k))
|
||||
return self._color_temp
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the device if any."""
|
||||
return self.device.name
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if device is on."""
|
||||
|
@ -892,6 +887,7 @@ class YeelightColorLightSupport(YeelightGenericLight):
|
|||
class YeelightWhiteTempLightSupport(YeelightGenericLight):
|
||||
"""Representation of a White temp Yeelight light."""
|
||||
|
||||
_attr_name = None
|
||||
_attr_color_mode = ColorMode.COLOR_TEMP
|
||||
_attr_supported_color_modes = {ColorMode.COLOR_TEMP}
|
||||
|
||||
|
@ -943,6 +939,8 @@ class YeelightColorLightWithNightlightSwitch(
|
|||
It represents case when nightlight switch is set to light.
|
||||
"""
|
||||
|
||||
_attr_name = None
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if device is on."""
|
||||
|
@ -954,6 +952,8 @@ class YeelightWhiteTempWithoutNightlightSwitch(
|
|||
):
|
||||
"""White temp light, when nightlight switch is not set to light."""
|
||||
|
||||
_attr_name = None
|
||||
|
||||
|
||||
class YeelightWithNightLight(
|
||||
YeelightNightLightSupport, YeelightWhiteTempLightSupport, YeelightGenericLight
|
||||
|
@ -963,6 +963,8 @@ class YeelightWithNightLight(
|
|||
It represents case when nightlight switch is set to light.
|
||||
"""
|
||||
|
||||
_attr_name = None
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if device is on."""
|
||||
|
@ -975,6 +977,7 @@ class YeelightNightLightMode(YeelightGenericLight):
|
|||
_attr_color_mode = ColorMode.BRIGHTNESS
|
||||
_attr_icon = "mdi:weather-night"
|
||||
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||
_attr_translation_key = "nightlight"
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
|
@ -982,11 +985,6 @@ class YeelightNightLightMode(YeelightGenericLight):
|
|||
unique = super().unique_id
|
||||
return f"{unique}-nightlight"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the device if any."""
|
||||
return f"{self.device.name} Nightlight"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if device is on."""
|
||||
|
@ -1030,6 +1028,8 @@ class YeelightWithAmbientWithoutNightlight(YeelightWhiteTempWithoutNightlightSwi
|
|||
And nightlight switch type is none.
|
||||
"""
|
||||
|
||||
_attr_name = None
|
||||
|
||||
@property
|
||||
def _power_property(self) -> str:
|
||||
return "main_power"
|
||||
|
@ -1041,6 +1041,8 @@ class YeelightWithAmbientAndNightlight(YeelightWithNightLight):
|
|||
And nightlight switch type is set to light.
|
||||
"""
|
||||
|
||||
_attr_name = None
|
||||
|
||||
@property
|
||||
def _power_property(self) -> str:
|
||||
return "main_power"
|
||||
|
@ -1049,6 +1051,8 @@ class YeelightWithAmbientAndNightlight(YeelightWithNightLight):
|
|||
class YeelightAmbientLight(YeelightColorLightWithoutNightlightSwitch):
|
||||
"""Representation of a Yeelight ambient light."""
|
||||
|
||||
_attr_translation_key = "ambilight"
|
||||
|
||||
PROPERTIES_MAPPING = {"color_mode": "bg_lmode"}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -1065,11 +1069,6 @@ class YeelightAmbientLight(YeelightColorLightWithoutNightlightSwitch):
|
|||
unique = super().unique_id
|
||||
return f"{unique}-ambilight"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the device if any."""
|
||||
return f"{self.device.name} Ambilight"
|
||||
|
||||
@property
|
||||
def _brightness_property(self) -> str:
|
||||
return "bright"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue