mirror of
https://github.com/home-assistant/core.git
synced 2025-05-02 21:19:16 +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)
|
super().__init__(coordinator)
|
||||||
self.xuid = xuid
|
self.xuid = xuid
|
||||||
self.attribute = attribute
|
self.attribute = attribute
|
||||||
|
self._attr_unique_id = f"{xuid}_{attribute}"
|
||||||
@property
|
self._attr_entity_registry_enabled_default = attribute == "online"
|
||||||
def unique_id(self) -> str:
|
self._attr_device_info = DeviceInfo(
|
||||||
"""Return a unique, Home Assistant friendly identifier for this entity."""
|
entry_type=DeviceEntryType.SERVICE,
|
||||||
return f"{self.xuid}_{self.attribute}"
|
identifiers={(DOMAIN, "xbox_live")},
|
||||||
|
manufacturer="Microsoft",
|
||||||
|
model="Xbox Live",
|
||||||
|
name="Xbox Live",
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self) -> PresenceData | None:
|
def data(self) -> PresenceData | None:
|
||||||
@ -61,19 +65,3 @@ class XboxBaseSensorEntity(CoordinatorEntity[XboxUpdateCoordinator]):
|
|||||||
query = dict(url.query)
|
query = dict(url.query)
|
||||||
query.pop("mode", None)
|
query.pop("mode", None)
|
||||||
return str(url.with_query(query))
|
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