Migrate Yale Smart Alarm to new entity naming style (#75202)
This commit is contained in:
parent
cba3c8cf65
commit
d2e5d01aca
4 changed files with 11 additions and 12 deletions
|
@ -14,7 +14,6 @@ from homeassistant.components.alarm_control_panel import (
|
|||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -47,7 +46,6 @@ class YaleAlarmDevice(YaleAlarmEntity, AlarmControlPanelEntity):
|
|||
def __init__(self, coordinator: YaleDataUpdateCoordinator) -> None:
|
||||
"""Initialize the Yale Alarm Device."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_name = coordinator.entry.data[CONF_NAME]
|
||||
self._attr_unique_id = coordinator.entry.entry_id
|
||||
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
|
|
|
@ -7,7 +7,6 @@ from homeassistant.components.binary_sensor import (
|
|||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -21,7 +20,7 @@ SENSOR_TYPES = (
|
|||
key="acfail",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
name="Power Loss",
|
||||
name="Power loss",
|
||||
),
|
||||
BinarySensorEntityDescription(
|
||||
key="battery",
|
||||
|
@ -85,9 +84,6 @@ class YaleProblemSensor(YaleAlarmEntity, BinarySensorEntity):
|
|||
"""Initiate Yale Problem Sensor."""
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = entity_description
|
||||
self._attr_name = (
|
||||
f"{coordinator.entry.data[CONF_NAME]} {entity_description.name}"
|
||||
)
|
||||
self._attr_unique_id = f"{coordinator.entry.entry_id}-{entity_description.key}"
|
||||
|
||||
@property
|
||||
|
|
|
@ -5,7 +5,6 @@ from typing import TYPE_CHECKING
|
|||
|
||||
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
|
@ -14,7 +13,11 @@ from .coordinator import YaleDataUpdateCoordinator
|
|||
from .entity import YaleAlarmEntity
|
||||
|
||||
BUTTON_TYPES = (
|
||||
ButtonEntityDescription(key="panic", name="Panic Button", icon="mdi:alarm-light"),
|
||||
ButtonEntityDescription(
|
||||
key="panic",
|
||||
name="Panic button",
|
||||
icon="mdi:alarm-light",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -47,7 +50,6 @@ class YalePanicButton(YaleAlarmEntity, ButtonEntity):
|
|||
"""Initialize the plug switch."""
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
self._attr_name = f"{coordinator.entry.data[CONF_NAME]} {description.name}"
|
||||
self._attr_unique_id = f"yale_smart_alarm-{description.key}"
|
||||
|
||||
async def async_press(self) -> None:
|
||||
|
|
|
@ -12,13 +12,14 @@ from .coordinator import YaleDataUpdateCoordinator
|
|||
class YaleEntity(CoordinatorEntity[YaleDataUpdateCoordinator], Entity):
|
||||
"""Base implementation for Yale device."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, coordinator: YaleDataUpdateCoordinator, data: dict) -> None:
|
||||
"""Initialize an Yale device."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_name: str = data["name"]
|
||||
self._attr_unique_id: str = data["address"]
|
||||
self._attr_device_info: DeviceInfo = DeviceInfo(
|
||||
name=self._attr_name,
|
||||
name=data["name"],
|
||||
manufacturer=MANUFACTURER,
|
||||
model=MODEL,
|
||||
identifiers={(DOMAIN, data["address"])},
|
||||
|
@ -29,6 +30,8 @@ class YaleEntity(CoordinatorEntity[YaleDataUpdateCoordinator], Entity):
|
|||
class YaleAlarmEntity(CoordinatorEntity[YaleDataUpdateCoordinator], Entity):
|
||||
"""Base implementation for Yale Alarm device."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, coordinator: YaleDataUpdateCoordinator) -> None:
|
||||
"""Initialize an Yale device."""
|
||||
super().__init__(coordinator)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue