mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Migrate Wilight to has entity name (#96825)
Migrate Wilight to has entity naming
This commit is contained in:
parent
d361caf6c4
commit
772fb463b5
@ -56,6 +56,7 @@ class WiLightDevice(Entity):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, api_device: PyWiLightDevice, index: str, item_name: str) -> None:
|
def __init__(self, api_device: PyWiLightDevice, index: str, item_name: str) -> None:
|
||||||
"""Initialize the device."""
|
"""Initialize the device."""
|
||||||
@ -65,7 +66,6 @@ class WiLightDevice(Entity):
|
|||||||
self._index = index
|
self._index = index
|
||||||
self._status: dict[str, Any] = {}
|
self._status: dict[str, Any] = {}
|
||||||
|
|
||||||
self._attr_name = item_name
|
|
||||||
self._attr_unique_id = f"{self._device_id}_{index}"
|
self._attr_unique_id = f"{self._device_id}_{index}"
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
name=item_name,
|
name=item_name,
|
||||||
|
@ -57,6 +57,8 @@ def hass_to_wilight_position(value: int) -> int:
|
|||||||
class WiLightCover(WiLightDevice, CoverEntity):
|
class WiLightCover(WiLightDevice, CoverEntity):
|
||||||
"""Representation of a WiLights cover."""
|
"""Representation of a WiLights cover."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_cover_position(self) -> int | None:
|
def current_cover_position(self) -> int | None:
|
||||||
"""Return current position of cover.
|
"""Return current position of cover.
|
||||||
|
@ -54,6 +54,7 @@ async def async_setup_entry(
|
|||||||
class WiLightFan(WiLightDevice, FanEntity):
|
class WiLightFan(WiLightDevice, FanEntity):
|
||||||
"""Representation of a WiLights fan."""
|
"""Representation of a WiLights fan."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
_attr_icon = "mdi:fan"
|
_attr_icon = "mdi:fan"
|
||||||
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
||||||
_attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.DIRECTION
|
_attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.DIRECTION
|
||||||
|
@ -53,6 +53,7 @@ async def async_setup_entry(
|
|||||||
class WiLightLightOnOff(WiLightDevice, LightEntity):
|
class WiLightLightOnOff(WiLightDevice, LightEntity):
|
||||||
"""Representation of a WiLights light on-off."""
|
"""Representation of a WiLights light on-off."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
_attr_color_mode = ColorMode.ONOFF
|
_attr_color_mode = ColorMode.ONOFF
|
||||||
_attr_supported_color_modes = {ColorMode.ONOFF}
|
_attr_supported_color_modes = {ColorMode.ONOFF}
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ class WiLightLightOnOff(WiLightDevice, LightEntity):
|
|||||||
class WiLightLightDimmer(WiLightDevice, LightEntity):
|
class WiLightLightDimmer(WiLightDevice, LightEntity):
|
||||||
"""Representation of a WiLights light dimmer."""
|
"""Representation of a WiLights light dimmer."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
_attr_color_mode = ColorMode.BRIGHTNESS
|
_attr_color_mode = ColorMode.BRIGHTNESS
|
||||||
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||||
|
|
||||||
@ -124,6 +126,7 @@ def hass_to_wilight_saturation(value: float) -> int:
|
|||||||
class WiLightLightColor(WiLightDevice, LightEntity):
|
class WiLightLightColor(WiLightDevice, LightEntity):
|
||||||
"""Representation of a WiLights light rgb."""
|
"""Representation of a WiLights light rgb."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
_attr_color_mode = ColorMode.HS
|
_attr_color_mode = ColorMode.HS
|
||||||
_attr_supported_color_modes = {ColorMode.HS}
|
_attr_supported_color_modes = {ColorMode.HS}
|
||||||
|
|
||||||
|
@ -12,6 +12,16 @@
|
|||||||
"not_wilight_device": "This Device is not WiLight"
|
"not_wilight_device": "This Device is not WiLight"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"entity": {
|
||||||
|
"switch": {
|
||||||
|
"watering": {
|
||||||
|
"name": "Watering"
|
||||||
|
},
|
||||||
|
"pause": {
|
||||||
|
"name": "Pause"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"services": {
|
"services": {
|
||||||
"set_watering_time": {
|
"set_watering_time": {
|
||||||
"name": "Set watering time",
|
"name": "Set watering time",
|
||||||
|
@ -148,10 +148,7 @@ def hass_to_wilight_pause_time(value: int) -> int:
|
|||||||
class WiLightValveSwitch(WiLightDevice, SwitchEntity):
|
class WiLightValveSwitch(WiLightDevice, SwitchEntity):
|
||||||
"""Representation of a WiLights Valve switch."""
|
"""Representation of a WiLights Valve switch."""
|
||||||
|
|
||||||
@property
|
_attr_translation_key = "watering"
|
||||||
def name(self) -> str:
|
|
||||||
"""Return the name of the switch."""
|
|
||||||
return f"{self._attr_name} {DESC_WATERING}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -272,10 +269,7 @@ class WiLightValveSwitch(WiLightDevice, SwitchEntity):
|
|||||||
class WiLightValvePauseSwitch(WiLightDevice, SwitchEntity):
|
class WiLightValvePauseSwitch(WiLightDevice, SwitchEntity):
|
||||||
"""Representation of a WiLights Valve Pause switch."""
|
"""Representation of a WiLights Valve Pause switch."""
|
||||||
|
|
||||||
@property
|
_attr_translation_key = "pause"
|
||||||
def name(self) -> str:
|
|
||||||
"""Return the name of the switch."""
|
|
||||||
return f"{self._attr_name} {DESC_PAUSE}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user