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

View file

@ -12,5 +12,24 @@
"create_entry": {
"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"
}
}
}
}