mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Migrate Skybell to new entity naming style (#75341)
This commit is contained in:
parent
460f522d6d
commit
27e3ff9c69
@ -41,7 +41,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
CAMERA_TYPES: tuple[CameraEntityDescription, ...] = (
|
CAMERA_TYPES: tuple[CameraEntityDescription, ...] = (
|
||||||
CameraEntityDescription(key="activity", name="Last Activity"),
|
CameraEntityDescription(key="activity", name="Last activity"),
|
||||||
CameraEntityDescription(key="avatar", name="Camera"),
|
CameraEntityDescription(key="avatar", name="Camera"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ class SkybellEntity(CoordinatorEntity[SkybellDataUpdateCoordinator]):
|
|||||||
"""An HA implementation for Skybell entity."""
|
"""An HA implementation for Skybell entity."""
|
||||||
|
|
||||||
_attr_attribution = "Data provided by Skybell.com"
|
_attr_attribution = "Data provided by Skybell.com"
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coordinator: SkybellDataUpdateCoordinator, description: EntityDescription
|
self, coordinator: SkybellDataUpdateCoordinator, description: EntityDescription
|
||||||
@ -23,14 +24,12 @@ class SkybellEntity(CoordinatorEntity[SkybellDataUpdateCoordinator]):
|
|||||||
"""Initialize a SkyBell entity."""
|
"""Initialize a SkyBell entity."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
if description.name != coordinator.device.name:
|
|
||||||
self._attr_name = f"{self._device.name} {description.name}"
|
|
||||||
self._attr_unique_id = f"{self._device.device_id}_{description.key}"
|
self._attr_unique_id = f"{self._device.device_id}_{description.key}"
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, self._device.device_id)},
|
identifiers={(DOMAIN, self._device.device_id)},
|
||||||
manufacturer=DEFAULT_NAME,
|
manufacturer=DEFAULT_NAME,
|
||||||
model=self._device.type,
|
model=self._device.type,
|
||||||
name=self._device.name,
|
name=self._device.name.capitalize(),
|
||||||
sw_version=self._device.firmware_ver,
|
sw_version=self._device.firmware_ver,
|
||||||
)
|
)
|
||||||
if self._device.mac:
|
if self._device.mac:
|
||||||
|
@ -23,13 +23,7 @@ async def async_setup_entry(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Skybell switch."""
|
"""Set up Skybell switch."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
SkybellLight(
|
SkybellLight(coordinator, LightEntityDescription(key="light"))
|
||||||
coordinator,
|
|
||||||
LightEntityDescription(
|
|
||||||
key=coordinator.device.name,
|
|
||||||
name=coordinator.device.name,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
for coordinator in hass.data[DOMAIN][entry.entry_id]
|
for coordinator in hass.data[DOMAIN][entry.entry_id]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,27 +35,27 @@ class SkybellSensorEntityDescription(SensorEntityDescription):
|
|||||||
SENSOR_TYPES: tuple[SkybellSensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SkybellSensorEntityDescription, ...] = (
|
||||||
SkybellSensorEntityDescription(
|
SkybellSensorEntityDescription(
|
||||||
key="chime_level",
|
key="chime_level",
|
||||||
name="Chime Level",
|
name="Chime level",
|
||||||
icon="mdi:bell-ring",
|
icon="mdi:bell-ring",
|
||||||
value_fn=lambda device: device.outdoor_chime_level,
|
value_fn=lambda device: device.outdoor_chime_level,
|
||||||
),
|
),
|
||||||
SkybellSensorEntityDescription(
|
SkybellSensorEntityDescription(
|
||||||
key="last_button_event",
|
key="last_button_event",
|
||||||
name="Last Button Event",
|
name="Last button event",
|
||||||
icon="mdi:clock",
|
icon="mdi:clock",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
value_fn=lambda device: device.latest("button").get(CONST.CREATED_AT),
|
value_fn=lambda device: device.latest("button").get(CONST.CREATED_AT),
|
||||||
),
|
),
|
||||||
SkybellSensorEntityDescription(
|
SkybellSensorEntityDescription(
|
||||||
key="last_motion_event",
|
key="last_motion_event",
|
||||||
name="Last Motion Event",
|
name="Last motion event",
|
||||||
icon="mdi:clock",
|
icon="mdi:clock",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
value_fn=lambda device: device.latest("motion").get(CONST.CREATED_AT),
|
value_fn=lambda device: device.latest("motion").get(CONST.CREATED_AT),
|
||||||
),
|
),
|
||||||
SkybellSensorEntityDescription(
|
SkybellSensorEntityDescription(
|
||||||
key=CONST.ATTR_LAST_CHECK_IN,
|
key=CONST.ATTR_LAST_CHECK_IN,
|
||||||
name="Last Check in",
|
name="Last check in",
|
||||||
icon="mdi:clock",
|
icon="mdi:clock",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
@ -64,7 +64,7 @@ SENSOR_TYPES: tuple[SkybellSensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
SkybellSensorEntityDescription(
|
SkybellSensorEntityDescription(
|
||||||
key="motion_threshold",
|
key="motion_threshold",
|
||||||
name="Motion Threshold",
|
name="Motion threshold",
|
||||||
icon="mdi:walk",
|
icon="mdi:walk",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
@ -72,7 +72,7 @@ SENSOR_TYPES: tuple[SkybellSensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
SkybellSensorEntityDescription(
|
SkybellSensorEntityDescription(
|
||||||
key="video_profile",
|
key="video_profile",
|
||||||
name="Video Profile",
|
name="Video profile",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda device: device.video_profile,
|
value_fn=lambda device: device.video_profile,
|
||||||
@ -87,7 +87,7 @@ SENSOR_TYPES: tuple[SkybellSensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
SkybellSensorEntityDescription(
|
SkybellSensorEntityDescription(
|
||||||
key=CONST.ATTR_WIFI_STATUS,
|
key=CONST.ATTR_WIFI_STATUS,
|
||||||
name="Wifi Status",
|
name="Wifi status",
|
||||||
icon="mdi:wifi-strength-3",
|
icon="mdi:wifi-strength-3",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -22,15 +22,15 @@ from .entity import SkybellEntity
|
|||||||
SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
|
SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
|
||||||
SwitchEntityDescription(
|
SwitchEntityDescription(
|
||||||
key="do_not_disturb",
|
key="do_not_disturb",
|
||||||
name="Do Not Disturb",
|
name="Do not disturb",
|
||||||
),
|
),
|
||||||
SwitchEntityDescription(
|
SwitchEntityDescription(
|
||||||
key="do_not_ring",
|
key="do_not_ring",
|
||||||
name="Do Not Ring",
|
name="Do not ring",
|
||||||
),
|
),
|
||||||
SwitchEntityDescription(
|
SwitchEntityDescription(
|
||||||
key="motion_sensor",
|
key="motion_sensor",
|
||||||
name="Motion Sensor",
|
name="Motion sensor",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user