Add entity translations for Ondilo Ico (#95809)

This commit is contained in:
Joost Lekkerkerker 2023-07-22 13:16:07 +02:00 committed by GitHub
parent 24b9bde9e5
commit e2fdc6a98b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 8 deletions

View file

@ -35,48 +35,46 @@ from .const import DOMAIN
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="temperature", key="temperature",
name="Temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="orp", key="orp",
name="Oxydo Reduction Potential", translation_key="oxydo_reduction_potential",
native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT, native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT,
icon="mdi:pool", icon="mdi:pool",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="ph", key="ph",
name="pH", translation_key="ph",
icon="mdi:pool", icon="mdi:pool",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="tds", key="tds",
name="TDS", translation_key="tds",
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
icon="mdi:pool", icon="mdi:pool",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="battery", key="battery",
name="Battery",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY, device_class=SensorDeviceClass.BATTERY,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="rssi", key="rssi",
name="RSSI", translation_key="rssi",
icon="mdi:wifi", icon="mdi:wifi",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="salt", key="salt",
name="Salt", translation_key="salt",
native_unit_of_measurement="mg/L", native_unit_of_measurement="mg/L",
icon="mdi:pool", icon="mdi:pool",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -139,6 +137,8 @@ class OndiloICO(
): ):
"""Representation of a Sensor.""" """Representation of a Sensor."""
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
coordinator: DataUpdateCoordinator[list[dict[str, Any]]], coordinator: DataUpdateCoordinator[list[dict[str, Any]]],
@ -154,7 +154,6 @@ class OndiloICO(
pooldata = self._pooldata() pooldata = self._pooldata()
self._attr_unique_id = f"{pooldata['ICO']['serial_number']}-{description.key}" self._attr_unique_id = f"{pooldata['ICO']['serial_number']}-{description.key}"
self._device_name = pooldata["name"] self._device_name = pooldata["name"]
self._attr_name = f"{self._device_name} {description.name}"
def _pooldata(self): def _pooldata(self):
"""Get pool data dict.""" """Get pool data dict."""

View file

@ -12,5 +12,24 @@
"create_entry": { "create_entry": {
"default": "[%key:common::config_flow::create_entry::authenticated%]" "default": "[%key:common::config_flow::create_entry::authenticated%]"
} }
},
"entity": {
"sensor": {
"oxydo_reduction_potential": {
"name": "Oxydo reduction potential"
},
"ph": {
"name": "pH"
},
"tds": {
"name": "TDS"
},
"rssi": {
"name": "RSSI"
},
"salt": {
"name": "Salt"
}
}
} }
} }