Migrate Agent DVR to has entity name (#96562)

pull/96872/head
Joost Lekkerkerker 2023-07-18 20:41:14 +02:00 committed by GitHub
parent 6afa49a441
commit 344f349371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -47,14 +47,16 @@ class AgentBaseStation(AlarmControlPanelEntity):
| AlarmControlPanelEntityFeature.ARM_AWAY | AlarmControlPanelEntityFeature.ARM_AWAY
| AlarmControlPanelEntityFeature.ARM_NIGHT | AlarmControlPanelEntityFeature.ARM_NIGHT
) )
_attr_has_entity_name = True
_attr_name = None
def __init__(self, client): def __init__(self, client):
"""Initialize the alarm control panel.""" """Initialize the alarm control panel."""
self._client = client self._client = client
self._attr_name = f"{client.name} {CONST_ALARM_CONTROL_PANEL_NAME}"
self._attr_unique_id = f"{client.unique}_CP" self._attr_unique_id = f"{client.unique}_CP"
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
identifiers={(AGENT_DOMAIN, client.unique)}, identifiers={(AGENT_DOMAIN, client.unique)},
name=f"{client.name} {CONST_ALARM_CONTROL_PANEL_NAME}",
manufacturer="Agent", manufacturer="Agent",
model=CONST_ALARM_CONTROL_PANEL_NAME, model=CONST_ALARM_CONTROL_PANEL_NAME,
sw_version=client.version, sw_version=client.version,

View File

@ -72,12 +72,13 @@ class AgentCamera(MjpegCamera):
_attr_attribution = ATTRIBUTION _attr_attribution = ATTRIBUTION
_attr_should_poll = True # Cameras default to False _attr_should_poll = True # Cameras default to False
_attr_supported_features = CameraEntityFeature.ON_OFF _attr_supported_features = CameraEntityFeature.ON_OFF
_attr_has_entity_name = True
_attr_name = None
def __init__(self, device): def __init__(self, device):
"""Initialize as a subclass of MjpegCamera.""" """Initialize as a subclass of MjpegCamera."""
self.device = device self.device = device
self._removed = False self._removed = False
self._attr_name = f"{device.client.name} {device.name}"
self._attr_unique_id = f"{device._client.unique}_{device.typeID}_{device.id}" self._attr_unique_id = f"{device._client.unique}_{device.typeID}_{device.id}"
super().__init__( super().__init__(
name=device.name, name=device.name,
@ -88,7 +89,7 @@ class AgentCamera(MjpegCamera):
identifiers={(AGENT_DOMAIN, self.unique_id)}, identifiers={(AGENT_DOMAIN, self.unique_id)},
manufacturer="Agent", manufacturer="Agent",
model="Camera", model="Camera",
name=self.name, name=f"{device.client.name} {device.name}",
sw_version=device.client.version, sw_version=device.client.version,
) )