mirror of
https://github.com/home-assistant/core
synced 2024-10-01 05:30:36 +02:00
Migrate SimpliSafe to new entity naming style (#74763)
This commit is contained in:
parent
5360e56d09
commit
ea1fc6b5d3
@ -113,8 +113,7 @@ ATTR_SYSTEM_ID = "system_id"
|
||||
ATTR_TIMESTAMP = "timestamp"
|
||||
|
||||
DEFAULT_CONFIG_URL = "https://webapp.simplisafe.com/new/#/dashboard"
|
||||
DEFAULT_ENTITY_MODEL = "alarm_control_panel"
|
||||
DEFAULT_ENTITY_NAME = "Alarm Control Panel"
|
||||
DEFAULT_ENTITY_MODEL = "Alarm control panel"
|
||||
DEFAULT_ERROR_THRESHOLD = 2
|
||||
DEFAULT_SCAN_INTERVAL = timedelta(seconds=30)
|
||||
DEFAULT_SOCKET_MIN_RETRY = 15
|
||||
@ -660,6 +659,8 @@ class SimpliSafe:
|
||||
class SimpliSafeEntity(CoordinatorEntity):
|
||||
"""Define a base SimpliSafe entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
simplisafe: SimpliSafe,
|
||||
@ -679,12 +680,11 @@ class SimpliSafeEntity(CoordinatorEntity):
|
||||
self._error_count = 0
|
||||
|
||||
if device:
|
||||
model = device.type.name
|
||||
device_name = device.name
|
||||
model = device.type.name.capitalize().replace("_", " ")
|
||||
device_name = f"{device.name.capitalize()} {model}"
|
||||
serial = device.serial
|
||||
else:
|
||||
model = DEFAULT_ENTITY_MODEL
|
||||
device_name = DEFAULT_ENTITY_NAME
|
||||
model = device_name = DEFAULT_ENTITY_MODEL
|
||||
serial = system.serial
|
||||
|
||||
event = simplisafe.initial_event_to_use[system.system_id]
|
||||
@ -714,7 +714,6 @@ class SimpliSafeEntity(CoordinatorEntity):
|
||||
via_device=(DOMAIN, system.system_id),
|
||||
)
|
||||
|
||||
self._attr_name = f"{system.address} {device_name} {' '.join([w.title() for w in model.split('_')])}"
|
||||
self._attr_unique_id = serial
|
||||
self._device = device
|
||||
self._online = True
|
||||
|
@ -103,7 +103,7 @@ class BatteryBinarySensor(SimpliSafeEntity, BinarySensorEntity):
|
||||
"""Initialize."""
|
||||
super().__init__(simplisafe, system, device=sensor)
|
||||
|
||||
self._attr_name = f"{super().name} Battery"
|
||||
self._attr_name = "Battery"
|
||||
self._attr_unique_id = f"{super().unique_id}-battery"
|
||||
self._device: SensorV3
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user