Add entity translations for ld2410 BLE (#95709)
This commit is contained in:
parent
672313c8ab
commit
33f2453f33
3 changed files with 92 additions and 22 deletions
|
@ -21,14 +21,10 @@ ENTITY_DESCRIPTIONS = (
|
|||
BinarySensorEntityDescription(
|
||||
key="is_moving",
|
||||
device_class=BinarySensorDeviceClass.MOTION,
|
||||
has_entity_name=True,
|
||||
name="Motion",
|
||||
),
|
||||
BinarySensorEntityDescription(
|
||||
key="is_static",
|
||||
device_class=BinarySensorDeviceClass.OCCUPANCY,
|
||||
has_entity_name=True,
|
||||
name="Occupancy",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -51,6 +47,8 @@ class LD2410BLEBinarySensor(
|
|||
):
|
||||
"""Moving/static sensor for LD2410BLE."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: LD2410BLECoordinator,
|
||||
|
|
|
@ -21,84 +21,76 @@ from .models import LD2410BLEData
|
|||
|
||||
MOVING_TARGET_DISTANCE_DESCRIPTION = SensorEntityDescription(
|
||||
key="moving_target_distance",
|
||||
translation_key="moving_target_distance",
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_registry_visible_default=True,
|
||||
has_entity_name=True,
|
||||
name="Moving Target Distance",
|
||||
native_unit_of_measurement=UnitOfLength.CENTIMETERS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
)
|
||||
|
||||
STATIC_TARGET_DISTANCE_DESCRIPTION = SensorEntityDescription(
|
||||
key="static_target_distance",
|
||||
translation_key="static_target_distance",
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_registry_visible_default=True,
|
||||
has_entity_name=True,
|
||||
name="Static Target Distance",
|
||||
native_unit_of_measurement=UnitOfLength.CENTIMETERS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
)
|
||||
|
||||
DETECTION_DISTANCE_DESCRIPTION = SensorEntityDescription(
|
||||
key="detection_distance",
|
||||
translation_key="detection_distance",
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_registry_visible_default=True,
|
||||
has_entity_name=True,
|
||||
name="Detection Distance",
|
||||
native_unit_of_measurement=UnitOfLength.CENTIMETERS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
)
|
||||
|
||||
MOVING_TARGET_ENERGY_DESCRIPTION = SensorEntityDescription(
|
||||
key="moving_target_energy",
|
||||
translation_key="moving_target_energy",
|
||||
device_class=None,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_registry_visible_default=True,
|
||||
has_entity_name=True,
|
||||
name="Moving Target Energy",
|
||||
native_unit_of_measurement="Target Energy",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
)
|
||||
|
||||
STATIC_TARGET_ENERGY_DESCRIPTION = SensorEntityDescription(
|
||||
key="static_target_energy",
|
||||
translation_key="static_target_energy",
|
||||
device_class=None,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_registry_visible_default=True,
|
||||
has_entity_name=True,
|
||||
name="Static Target Energy",
|
||||
native_unit_of_measurement="Target Energy",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
)
|
||||
|
||||
MAX_MOTION_GATES_DESCRIPTION = SensorEntityDescription(
|
||||
key="max_motion_gates",
|
||||
translation_key="max_motion_gates",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
has_entity_name=True,
|
||||
name="Max Motion Gates",
|
||||
native_unit_of_measurement="Gates",
|
||||
)
|
||||
|
||||
MAX_STATIC_GATES_DESCRIPTION = SensorEntityDescription(
|
||||
key="max_static_gates",
|
||||
translation_key="max_static_gates",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
has_entity_name=True,
|
||||
name="Max Static Gates",
|
||||
native_unit_of_measurement="Gates",
|
||||
)
|
||||
|
||||
MOTION_ENERGY_GATES = [
|
||||
SensorEntityDescription(
|
||||
key=f"motion_energy_gate_{i}",
|
||||
translation_key=f"motion_energy_gate_{i}",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
has_entity_name=True,
|
||||
name=f"Motion Energy Gate {i}",
|
||||
native_unit_of_measurement="Target Energy",
|
||||
)
|
||||
for i in range(0, 9)
|
||||
|
@ -107,10 +99,9 @@ MOTION_ENERGY_GATES = [
|
|||
STATIC_ENERGY_GATES = [
|
||||
SensorEntityDescription(
|
||||
key=f"static_energy_gate_{i}",
|
||||
translation_key=f"static_energy_gate_{i}",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
has_entity_name=True,
|
||||
name=f"Static Energy Gate {i}",
|
||||
native_unit_of_measurement="Target Energy",
|
||||
)
|
||||
for i in range(0, 9)
|
||||
|
@ -152,6 +143,8 @@ async def async_setup_entry(
|
|||
class LD2410BLESensor(CoordinatorEntity[LD2410BLECoordinator], SensorEntity):
|
||||
"""Generic sensor for LD2410BLE."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: LD2410BLECoordinator,
|
||||
|
|
|
@ -18,5 +18,84 @@
|
|||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"moving_target_distance": {
|
||||
"name": "Moving target distance"
|
||||
},
|
||||
"static_target_distance": {
|
||||
"name": "Static target distance"
|
||||
},
|
||||
"detection_distance": {
|
||||
"name": "Detection distance"
|
||||
},
|
||||
"moving_target_energy": {
|
||||
"name": "Moving target energy"
|
||||
},
|
||||
"static_target_energy": {
|
||||
"name": "Static target energy"
|
||||
},
|
||||
"max_motion_gates": {
|
||||
"name": "Max motion gates"
|
||||
},
|
||||
"max_static_gates": {
|
||||
"name": "Max static gates"
|
||||
},
|
||||
"motion_energy_gate_0": {
|
||||
"name": "Motion energy gate 0"
|
||||
},
|
||||
"motion_energy_gate_1": {
|
||||
"name": "Motion energy gate 1"
|
||||
},
|
||||
"motion_energy_gate_2": {
|
||||
"name": "Motion energy gate 2"
|
||||
},
|
||||
"motion_energy_gate_3": {
|
||||
"name": "Motion energy gate 3"
|
||||
},
|
||||
"motion_energy_gate_4": {
|
||||
"name": "Motion energy gate 4"
|
||||
},
|
||||
"motion_energy_gate_5": {
|
||||
"name": "Motion energy gate 5"
|
||||
},
|
||||
"motion_energy_gate_6": {
|
||||
"name": "Motion energy gate 6"
|
||||
},
|
||||
"motion_energy_gate_7": {
|
||||
"name": "Motion energy gate 7"
|
||||
},
|
||||
"motion_energy_gate_8": {
|
||||
"name": "Motion energy gate 8"
|
||||
},
|
||||
"static_energy_gate_0": {
|
||||
"name": "Static energy gate 0"
|
||||
},
|
||||
"static_energy_gate_1": {
|
||||
"name": "Static energy gate 1"
|
||||
},
|
||||
"static_energy_gate_2": {
|
||||
"name": "Static energy gate 2"
|
||||
},
|
||||
"static_energy_gate_3": {
|
||||
"name": "Static energy gate 3"
|
||||
},
|
||||
"static_energy_gate_4": {
|
||||
"name": "Static energy gate 4"
|
||||
},
|
||||
"static_energy_gate_5": {
|
||||
"name": "Static energy gate 5"
|
||||
},
|
||||
"static_energy_gate_6": {
|
||||
"name": "Static energy gate 6"
|
||||
},
|
||||
"static_energy_gate_7": {
|
||||
"name": "Static energy gate 7"
|
||||
},
|
||||
"static_energy_gate_8": {
|
||||
"name": "Static energy gate 8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue