Add entity translations to Aseko (#98117)
This commit is contained in:
parent
9ce033daeb
commit
11b1a42a1c
4 changed files with 34 additions and 9 deletions
|
@ -37,19 +37,18 @@ class AsekoBinarySensorEntityDescription(
|
|||
UNIT_BINARY_SENSORS: tuple[AsekoBinarySensorEntityDescription, ...] = (
|
||||
AsekoBinarySensorEntityDescription(
|
||||
key="water_flow",
|
||||
name="Water Flow",
|
||||
translation_key="water_flow",
|
||||
icon="mdi:waves-arrow-right",
|
||||
value_fn=lambda unit: unit.water_flow,
|
||||
),
|
||||
AsekoBinarySensorEntityDescription(
|
||||
key="has_alarm",
|
||||
name="Alarm",
|
||||
translation_key="alarm",
|
||||
value_fn=lambda unit: unit.has_alarm,
|
||||
device_class=BinarySensorDeviceClass.SAFETY,
|
||||
),
|
||||
AsekoBinarySensorEntityDescription(
|
||||
key="has_error",
|
||||
name="Error",
|
||||
value_fn=lambda unit: unit.has_error,
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
),
|
||||
|
|
|
@ -11,6 +11,8 @@ from .coordinator import AsekoDataUpdateCoordinator
|
|||
class AsekoEntity(CoordinatorEntity[AsekoDataUpdateCoordinator]):
|
||||
"""Representation of an aseko entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, unit: Unit, coordinator: AsekoDataUpdateCoordinator) -> None:
|
||||
"""Initialize the aseko entity."""
|
||||
super().__init__(coordinator)
|
||||
|
|
|
@ -45,13 +45,16 @@ class VariableSensorEntity(AsekoEntity, SensorEntity):
|
|||
super().__init__(unit, coordinator)
|
||||
self._variable = variable
|
||||
|
||||
variable_name = {
|
||||
"Air temp.": "Air Temperature",
|
||||
"Cl free": "Free Chlorine",
|
||||
"Water temp.": "Water Temperature",
|
||||
}.get(self._variable.name, self._variable.name)
|
||||
translation_key = {
|
||||
"Air temp.": "air_temperature",
|
||||
"Cl free": "free_chlorine",
|
||||
"Water temp.": "water_temperature",
|
||||
}.get(self._variable.name)
|
||||
if translation_key is not None:
|
||||
self._attr_translation_key = translation_key
|
||||
else:
|
||||
self._attr_name = self._variable.name
|
||||
|
||||
self._attr_name = f"{self._device_name} {variable_name}"
|
||||
self._attr_unique_id = f"{self._unit.serial_number}{self._variable.type}"
|
||||
self._attr_native_unit_of_measurement = self._variable.unit
|
||||
|
||||
|
|
|
@ -16,5 +16,26 @@
|
|||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"water_flow": {
|
||||
"name": "Water flow"
|
||||
},
|
||||
"alarm": {
|
||||
"name": "Alarm"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"air_temperature": {
|
||||
"name": "Air temperature"
|
||||
},
|
||||
"free_chlorine": {
|
||||
"name": "Free chlorine"
|
||||
},
|
||||
"water_temperature": {
|
||||
"name": "Water temperature"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue