1
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:
Aaron Bach 2022-07-09 11:59:36 -06:00 committed by GitHub
parent 5360e56d09
commit ea1fc6b5d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -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

View File

@ -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