From 56327458dc13d398ea06de8c17106d03e832f7a9 Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Wed, 4 Sep 2024 18:45:21 +0100 Subject: [PATCH] Update post review --- homeassistant/components/ring/binary_sensor.py | 14 ++++---------- homeassistant/components/ring/event.py | 16 ++++------------ homeassistant/components/ring/sensor.py | 4 ++-- homeassistant/components/ring/strings.json | 3 --- tests/components/ring/common.py | 2 +- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/homeassistant/components/ring/binary_sensor.py b/homeassistant/components/ring/binary_sensor.py index 45985fa17b460d..101894defaf222 100644 --- a/homeassistant/components/ring/binary_sensor.py +++ b/homeassistant/components/ring/binary_sensor.py @@ -45,20 +45,18 @@ class RingBinarySensorEntityDescription( key=KIND_DING, translation_key=KIND_DING, device_class=BinarySensorDeviceClass.OCCUPANCY, - entity_registry_enabled_default=True, capability=RingCapability.DING, deprecated_info=DeprecatedInfo( - new_platform=Platform.EVENT, breaks_in_ha_version="2025.3.0" + new_platform=Platform.EVENT, breaks_in_ha_version="2025.4.0" ), ), RingBinarySensorEntityDescription( key=KIND_MOTION, translation_key=KIND_MOTION, device_class=BinarySensorDeviceClass.MOTION, - entity_registry_enabled_default=True, capability=RingCapability.MOTION_DETECTION, deprecated_info=DeprecatedInfo( - new_platform=Platform.EVENT, breaks_in_ha_version="2025.3.0" + new_platform=Platform.EVENT, breaks_in_ha_version="2025.4.0" ), ), ) @@ -73,7 +71,7 @@ async def async_setup_entry( ring_data = entry.runtime_data listen_coordinator = ring_data.listen_coordinator - entities = [ + async_add_entities( RingBinarySensor(device, listen_coordinator, description) for description in BINARY_SENSOR_TYPES for device in ring_data.devices.all_devices @@ -84,8 +82,7 @@ async def async_setup_entry( f"{device.id}-{description.key}", description, ) - ] - async_add_entities(entities) + ) class RingBinarySensor( @@ -109,9 +106,6 @@ def __init__( ) self.entity_description = description self._attr_unique_id = f"{device.id}-{description.key}" - self._attr_entity_registry_enabled_default = ( - description.entity_registry_enabled_default - ) self._attr_is_on = False self._active_alert: RingEvent | None = None self._cancel_callback: TimerHandle | None = None diff --git a/homeassistant/components/ring/event.py b/homeassistant/components/ring/event.py index 5138b757177b30..bac0cba754b786 100644 --- a/homeassistant/components/ring/event.py +++ b/homeassistant/components/ring/event.py @@ -32,7 +32,6 @@ class RingEventEntityDescription(EventEntityDescription, Generic[RingDeviceT]): translation_key=KIND_DING, device_class=EventDeviceClass.DOORBELL, event_types=[KIND_DING], - entity_registry_enabled_default=True, capability=RingCapability.DING, ), RingEventEntityDescription( @@ -40,7 +39,6 @@ class RingEventEntityDescription(EventEntityDescription, Generic[RingDeviceT]): translation_key=KIND_MOTION, device_class=EventDeviceClass.MOTION, event_types=[KIND_MOTION], - entity_registry_enabled_default=True, capability=RingCapability.MOTION_DETECTION, ), RingEventEntityDescription( @@ -48,7 +46,6 @@ class RingEventEntityDescription(EventEntityDescription, Generic[RingDeviceT]): translation_key=KIND_INTERCOM_UNLOCK, device_class=EventDeviceClass.BUTTON, event_types=[KIND_INTERCOM_UNLOCK], - entity_registry_enabled_default=True, capability=RingCapability.OPEN, ), ) @@ -59,22 +56,20 @@ async def async_setup_entry( entry: RingConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: - """Set up a sensor for a Ring device.""" + """Set up events for a Ring device.""" ring_data = entry.runtime_data listen_coordinator = ring_data.listen_coordinator - entities = [ + async_add_entities( RingEvent(device, listen_coordinator, description) for description in EVENT_DESCRIPTIONS for device in ring_data.devices.all_devices if device.has_capability(description.capability) - ] - - async_add_entities(entities) + ) class RingEvent(RingBaseEntity[RingListenCoordinator, RingDeviceT], EventEntity): - """A sensor implementation for Ring device.""" + """An event implementation for Ring device.""" entity_description: RingEventEntityDescription[RingDeviceT] @@ -88,9 +83,6 @@ def __init__( super().__init__(device, coordinator) self.entity_description = description self._attr_unique_id = f"{device.id}-{description.key}" - self._attr_entity_registry_enabled_default = ( - description.entity_registry_enabled_default - ) @callback def _async_handle_event(self, event: str) -> None: diff --git a/homeassistant/components/ring/sensor.py b/homeassistant/components/ring/sensor.py index b2c0b51cd46013..219f1b0224cb4e 100644 --- a/homeassistant/components/ring/sensor.py +++ b/homeassistant/components/ring/sensor.py @@ -188,7 +188,7 @@ class RingSensorEntityDescription( else None, exists_fn=lambda device: device.has_capability(RingCapability.HISTORY), deprecated_info=DeprecatedInfo( - new_platform=Platform.EVENT, breaks_in_ha_version="2025.3.0" + new_platform=Platform.EVENT, breaks_in_ha_version="2025.4.0" ), ), RingSensorEntityDescription[RingGeneric]( @@ -207,7 +207,7 @@ class RingSensorEntityDescription( else None, exists_fn=lambda device: device.has_capability(RingCapability.HISTORY), deprecated_info=DeprecatedInfo( - new_platform=Platform.EVENT, breaks_in_ha_version="2025.3.0" + new_platform=Platform.EVENT, breaks_in_ha_version="2025.4.0" ), ), RingSensorEntityDescription[RingDoorBell | RingChime]( diff --git a/homeassistant/components/ring/strings.json b/homeassistant/components/ring/strings.json index 308ffeda9c1ad1..a15a51f224601d 100644 --- a/homeassistant/components/ring/strings.json +++ b/homeassistant/components/ring/strings.json @@ -44,9 +44,6 @@ "ding": { "name": "Ding" }, - "motion": { - "name": "Motion" - }, "intercom_unlock": { "name": "Intercom unlock" } diff --git a/tests/components/ring/common.py b/tests/components/ring/common.py index a2e016efbed402..71274fe1ee1786 100644 --- a/tests/components/ring/common.py +++ b/tests/components/ring/common.py @@ -21,7 +21,7 @@ async def setup_platform(hass: HomeAssistant, platform: Platform) -> None: await hass.async_block_till_done(wait_background_tasks=True) -async def setup_automation(hass: HomeAssistant, alias: str, entity_id: str): +async def setup_automation(hass: HomeAssistant, alias: str, entity_id: str) -> None: """Set up an automation for tests.""" assert await async_setup_component( hass,