Add entity translations to Flipr (#95344)
This commit is contained in:
parent
f61332c9b4
commit
968bc25259
5 changed files with 39 additions and 14 deletions
|
@ -15,7 +15,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||
UpdateFailed,
|
||||
)
|
||||
|
||||
from .const import ATTRIBUTION, CONF_FLIPR_ID, DOMAIN, MANUFACTURER, NAME
|
||||
from .const import ATTRIBUTION, CONF_FLIPR_ID, DOMAIN, MANUFACTURER
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -84,6 +84,7 @@ class FliprEntity(CoordinatorEntity):
|
|||
"""Implements a common class elements representing the Flipr component."""
|
||||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self, coordinator: DataUpdateCoordinator, description: EntityDescription
|
||||
|
@ -98,7 +99,5 @@ class FliprEntity(CoordinatorEntity):
|
|||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, flipr_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=NAME,
|
||||
name=f"Flipr {flipr_id}",
|
||||
)
|
||||
|
||||
self._attr_name = f"Flipr {flipr_id} {description.name}"
|
||||
|
|
|
@ -16,12 +16,12 @@ from .const import DOMAIN
|
|||
BINARY_SENSORS_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||
BinarySensorEntityDescription(
|
||||
key="ph_status",
|
||||
name="PH Status",
|
||||
translation_key="ph_status",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
),
|
||||
BinarySensorEntityDescription(
|
||||
key="chlorine_status",
|
||||
name="Chlorine Status",
|
||||
translation_key="chlorine_status",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -18,39 +18,38 @@ from .const import DOMAIN
|
|||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
SensorEntityDescription(
|
||||
key="chlorine",
|
||||
name="Chlorine",
|
||||
translation_key="chlorine",
|
||||
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="temperature",
|
||||
name="Water Temp",
|
||||
translation_key="water_temperature",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="date_time",
|
||||
name="Last Measured",
|
||||
translation_key="last_measured",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="red_ox",
|
||||
name="Red OX",
|
||||
translation_key="red_ox",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT,
|
||||
icon="mdi:pool",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="battery",
|
||||
name="Battery Level",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
|
|
|
@ -26,5 +26,32 @@
|
|||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"ph_status": {
|
||||
"name": "pH status"
|
||||
},
|
||||
"chlorine_status": {
|
||||
"name": "Chlorine status"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"chlorine": {
|
||||
"name": "Chlorine"
|
||||
},
|
||||
"ph": {
|
||||
"name": "pH"
|
||||
},
|
||||
"water_temperature": {
|
||||
"name": "Water temperature"
|
||||
},
|
||||
"last_measured": {
|
||||
"name": "Last measured"
|
||||
},
|
||||
"red_ox": {
|
||||
"name": "Red OX"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ async def test_sensors(hass: HomeAssistant, entity_registry: er.EntityRegistry)
|
|||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||
assert state.state == "7.03"
|
||||
|
||||
state = hass.states.get("sensor.flipr_myfliprid_water_temp")
|
||||
state = hass.states.get("sensor.flipr_myfliprid_water_temperature")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) is None
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
||||
|
@ -94,7 +94,7 @@ async def test_sensors(hass: HomeAssistant, entity_registry: er.EntityRegistry)
|
|||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||
assert state.state == "0.23654886"
|
||||
|
||||
state = hass.states.get("sensor.flipr_myfliprid_battery_level")
|
||||
state = hass.states.get("sensor.flipr_myfliprid_battery")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) is None
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||
|
|
Loading…
Add table
Reference in a new issue