mirror of
https://github.com/home-assistant/core
synced 2024-09-09 12:51:22 +02:00
Migrate Wiz to new entity naming style (#74911)
This commit is contained in:
parent
23f2e9014e
commit
bb4b2014fc
@ -66,12 +66,12 @@ class WizOccupancyEntity(WizEntity, BinarySensorEntity):
|
|||||||
"""Representation of WiZ Occupancy sensor."""
|
"""Representation of WiZ Occupancy sensor."""
|
||||||
|
|
||||||
_attr_device_class = BinarySensorDeviceClass.OCCUPANCY
|
_attr_device_class = BinarySensorDeviceClass.OCCUPANCY
|
||||||
|
_attr_name = "Occupancy"
|
||||||
|
|
||||||
def __init__(self, wiz_data: WizData, name: str) -> None:
|
def __init__(self, wiz_data: WizData, name: str) -> None:
|
||||||
"""Initialize an WiZ device."""
|
"""Initialize an WiZ device."""
|
||||||
super().__init__(wiz_data, name)
|
super().__init__(wiz_data, name)
|
||||||
self._attr_unique_id = OCCUPANCY_UNIQUE_ID.format(self._device.mac)
|
self._attr_unique_id = OCCUPANCY_UNIQUE_ID.format(self._device.mac)
|
||||||
self._attr_name = f"{name} Occupancy"
|
|
||||||
self._async_update_attrs()
|
self._async_update_attrs()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -21,13 +21,14 @@ from .models import WizData
|
|||||||
class WizEntity(CoordinatorEntity[DataUpdateCoordinator[Optional[float]]], Entity):
|
class WizEntity(CoordinatorEntity[DataUpdateCoordinator[Optional[float]]], Entity):
|
||||||
"""Representation of WiZ entity."""
|
"""Representation of WiZ entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, wiz_data: WizData, name: str) -> None:
|
def __init__(self, wiz_data: WizData, name: str) -> None:
|
||||||
"""Initialize a WiZ entity."""
|
"""Initialize a WiZ entity."""
|
||||||
super().__init__(wiz_data.coordinator)
|
super().__init__(wiz_data.coordinator)
|
||||||
self._device = wiz_data.bulb
|
self._device = wiz_data.bulb
|
||||||
bulb_type: BulbType = self._device.bulbtype
|
bulb_type: BulbType = self._device.bulbtype
|
||||||
self._attr_unique_id = self._device.mac
|
self._attr_unique_id = self._device.mac
|
||||||
self._attr_name = name
|
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
connections={(CONNECTION_NETWORK_MAC, self._device.mac)},
|
connections={(CONNECTION_NETWORK_MAC, self._device.mac)},
|
||||||
name=name,
|
name=name,
|
||||||
|
@ -52,7 +52,7 @@ NUMBERS: tuple[WizNumberEntityDescription, ...] = (
|
|||||||
native_max_value=200,
|
native_max_value=200,
|
||||||
native_step=1,
|
native_step=1,
|
||||||
icon="mdi:speedometer",
|
icon="mdi:speedometer",
|
||||||
name="Effect Speed",
|
name="Effect speed",
|
||||||
value_fn=lambda device: cast(Optional[int], device.state.get_speed()),
|
value_fn=lambda device: cast(Optional[int], device.state.get_speed()),
|
||||||
set_value_fn=_async_set_speed,
|
set_value_fn=_async_set_speed,
|
||||||
required_feature="effect",
|
required_feature="effect",
|
||||||
@ -63,7 +63,7 @@ NUMBERS: tuple[WizNumberEntityDescription, ...] = (
|
|||||||
native_max_value=100,
|
native_max_value=100,
|
||||||
native_step=1,
|
native_step=1,
|
||||||
icon="mdi:floor-lamp-dual",
|
icon="mdi:floor-lamp-dual",
|
||||||
name="Dual Head Ratio",
|
name="Dual head ratio",
|
||||||
value_fn=lambda device: cast(Optional[int], device.state.get_ratio()),
|
value_fn=lambda device: cast(Optional[int], device.state.get_ratio()),
|
||||||
set_value_fn=_async_set_ratio,
|
set_value_fn=_async_set_ratio,
|
||||||
required_feature="dual_head",
|
required_feature="dual_head",
|
||||||
@ -98,7 +98,6 @@ class WizSpeedNumber(WizEntity, NumberEntity):
|
|||||||
super().__init__(wiz_data, name)
|
super().__init__(wiz_data, name)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_unique_id = f"{self._device.mac}_{description.key}"
|
self._attr_unique_id = f"{self._device.mac}_{description.key}"
|
||||||
self._attr_name = f"{name} {description.name}"
|
|
||||||
self._async_update_attrs()
|
self._async_update_attrs()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -20,7 +20,7 @@ from .models import WizData
|
|||||||
SENSORS: tuple[SensorEntityDescription, ...] = (
|
SENSORS: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="rssi",
|
key="rssi",
|
||||||
name="Signal Strength",
|
name="Signal strength",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||||
@ -33,7 +33,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||||||
POWER_SENSORS: tuple[SensorEntityDescription, ...] = (
|
POWER_SENSORS: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="power",
|
key="power",
|
||||||
name="Current Power",
|
name="Current power",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=POWER_WATT,
|
||||||
@ -73,7 +73,6 @@ class WizSensor(WizEntity, SensorEntity):
|
|||||||
super().__init__(wiz_data, name)
|
super().__init__(wiz_data, name)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_unique_id = f"{self._device.mac}_{description.key}"
|
self._attr_unique_id = f"{self._device.mac}_{description.key}"
|
||||||
self._attr_name = f"{name} {description.name}"
|
|
||||||
self._async_update_attrs()
|
self._async_update_attrs()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
Loading…
Reference in New Issue
Block a user