Add entity name translations to SMS (#90727)

This commit is contained in:
Michael 2023-04-04 12:58:42 +02:00 committed by GitHub
parent 2f22613cf9
commit b4e12d34f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 8 deletions

View File

@ -17,7 +17,7 @@ from .const import DOMAIN, GATEWAY, NETWORK_COORDINATOR, SIGNAL_COORDINATOR, SMS
SIGNAL_SENSORS = ( SIGNAL_SENSORS = (
SensorEntityDescription( SensorEntityDescription(
key="SignalStrength", key="SignalStrength",
name="Signal Strength", translation_key="signal_strength",
device_class=SensorDeviceClass.SIGNAL_STRENGTH, device_class=SensorDeviceClass.SIGNAL_STRENGTH,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS, native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
@ -27,14 +27,14 @@ SIGNAL_SENSORS = (
SensorEntityDescription( SensorEntityDescription(
key="SignalPercent", key="SignalPercent",
icon="mdi:signal-cellular-3", icon="mdi:signal-cellular-3",
name="Signal Percent", translation_key="signal_percent",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
entity_registry_enabled_default=True, entity_registry_enabled_default=True,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="BitErrorRate", key="BitErrorRate",
name="Bit Error Rate", translation_key="bit_error_rate",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -45,31 +45,31 @@ SIGNAL_SENSORS = (
NETWORK_SENSORS = ( NETWORK_SENSORS = (
SensorEntityDescription( SensorEntityDescription(
key="NetworkName", key="NetworkName",
name="Network Name", translation_key="network_name",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
SensorEntityDescription( SensorEntityDescription(
key="State", key="State",
name="Network Status", translation_key="state",
entity_registry_enabled_default=True, entity_registry_enabled_default=True,
), ),
SensorEntityDescription( SensorEntityDescription(
key="NetworkCode", key="NetworkCode",
name="GSM network code", translation_key="network_code",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
SensorEntityDescription( SensorEntityDescription(
key="CID", key="CID",
name="Cell ID", translation_key="cid",
icon="mdi:radio-tower", icon="mdi:radio-tower",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
SensorEntityDescription( SensorEntityDescription(
key="LAC", key="LAC",
name="Local Area Code", translation_key="lac",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -102,6 +102,8 @@ async def async_setup_entry(
class DeviceSensor(CoordinatorEntity, SensorEntity): class DeviceSensor(CoordinatorEntity, SensorEntity):
"""Implementation of a device sensor.""" """Implementation of a device sensor."""
_attr_has_entity_name = True
def __init__(self, coordinator, description, unique_id, gateway): def __init__(self, coordinator, description, unique_id, gateway):
"""Initialize the device sensor.""" """Initialize the device sensor."""
super().__init__(coordinator) super().__init__(coordinator)

View File

@ -17,5 +17,19 @@
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]", "already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]" "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
} }
},
"entity": {
"sensor": {
"bit_error_rate": { "name": "Bit error rate" },
"cid": { "name": "Cell ID" },
"lac": { "name": "Local area code" },
"network_code": { "name": "GSM network code" },
"network_name": { "name": "Network name" },
"signal_percent": { "name": "Signal percent" },
"signal_strength": {
"name": "[%key:component::sensor::entity_component::signal_strength::name%]"
},
"state": { "name": "Network status" }
}
} }
} }