mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Use shorthand attrs for xbox base_sensor (#100290)
This commit is contained in:
parent
65c9e5ee13
commit
d44db6ee68
@ -20,11 +20,15 @@ class XboxBaseSensorEntity(CoordinatorEntity[XboxUpdateCoordinator]):
|
||||
super().__init__(coordinator)
|
||||
self.xuid = xuid
|
||||
self.attribute = attribute
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return a unique, Home Assistant friendly identifier for this entity."""
|
||||
return f"{self.xuid}_{self.attribute}"
|
||||
self._attr_unique_id = f"{xuid}_{attribute}"
|
||||
self._attr_entity_registry_enabled_default = attribute == "online"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
identifiers={(DOMAIN, "xbox_live")},
|
||||
manufacturer="Microsoft",
|
||||
model="Xbox Live",
|
||||
name="Xbox Live",
|
||||
)
|
||||
|
||||
@property
|
||||
def data(self) -> PresenceData | None:
|
||||
@ -61,19 +65,3 @@ class XboxBaseSensorEntity(CoordinatorEntity[XboxUpdateCoordinator]):
|
||||
query = dict(url.query)
|
||||
query.pop("mode", None)
|
||||
return str(url.with_query(query))
|
||||
|
||||
@property
|
||||
def entity_registry_enabled_default(self) -> bool:
|
||||
"""Return if the entity should be enabled when first added to the entity registry."""
|
||||
return self.attribute == "online"
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return a device description for device registry."""
|
||||
return DeviceInfo(
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
identifiers={(DOMAIN, "xbox_live")},
|
||||
manufacturer="Microsoft",
|
||||
model="Xbox Live",
|
||||
name="Xbox Live",
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user