Add entity translations to FiveM (#95370)
parent
4b9bfe9a50
commit
1a8bc1930c
|
@ -24,7 +24,7 @@ class FiveMBinarySensorEntityDescription(
|
|||
BINARY_SENSORS: tuple[FiveMBinarySensorEntityDescription, ...] = (
|
||||
FiveMBinarySensorEntityDescription(
|
||||
key=NAME_STATUS,
|
||||
name=NAME_STATUS,
|
||||
translation_key="status",
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -30,6 +30,8 @@ class FiveMEntityDescription(EntityDescription):
|
|||
class FiveMEntity(CoordinatorEntity[FiveMDataUpdateCoordinator]):
|
||||
"""Representation of a FiveM base entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
entity_description: FiveMEntityDescription
|
||||
|
||||
def __init__(
|
||||
|
@ -41,7 +43,6 @@ class FiveMEntity(CoordinatorEntity[FiveMDataUpdateCoordinator]):
|
|||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
|
||||
self._attr_name = f"{self.coordinator.host} {description.name}"
|
||||
self._attr_unique_id = f"{self.coordinator.unique_id}-{description.key}".lower()
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self.coordinator.unique_id)},
|
||||
|
|
|
@ -32,20 +32,20 @@ class FiveMSensorEntityDescription(SensorEntityDescription, FiveMEntityDescripti
|
|||
SENSORS: tuple[FiveMSensorEntityDescription, ...] = (
|
||||
FiveMSensorEntityDescription(
|
||||
key=NAME_PLAYERS_MAX,
|
||||
name=NAME_PLAYERS_MAX,
|
||||
translation_key="max_players",
|
||||
icon=ICON_PLAYERS_MAX,
|
||||
native_unit_of_measurement=UNIT_PLAYERS_MAX,
|
||||
),
|
||||
FiveMSensorEntityDescription(
|
||||
key=NAME_PLAYERS_ONLINE,
|
||||
name=NAME_PLAYERS_ONLINE,
|
||||
translation_key="online_players",
|
||||
icon=ICON_PLAYERS_ONLINE,
|
||||
native_unit_of_measurement=UNIT_PLAYERS_ONLINE,
|
||||
extra_attrs=[ATTR_PLAYERS_LIST],
|
||||
),
|
||||
FiveMSensorEntityDescription(
|
||||
key=NAME_RESOURCES,
|
||||
name=NAME_RESOURCES,
|
||||
translation_key="resources",
|
||||
icon=ICON_RESOURCES,
|
||||
native_unit_of_measurement=UNIT_RESOURCES,
|
||||
extra_attrs=[ATTR_RESOURCES_LIST],
|
||||
|
|
|
@ -17,5 +17,23 @@
|
|||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"status": {
|
||||
"name": "Status"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"max_players": {
|
||||
"name": "Players max"
|
||||
},
|
||||
"online_players": {
|
||||
"name": "Players online"
|
||||
},
|
||||
"resources": {
|
||||
"name": "Resources"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue