mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add entity translations to Flipr (#95344)
This commit is contained in:
parent
f61332c9b4
commit
968bc25259
@ -15,7 +15,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||||||
UpdateFailed,
|
UpdateFailed,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .const import ATTRIBUTION, CONF_FLIPR_ID, DOMAIN, MANUFACTURER, NAME
|
from .const import ATTRIBUTION, CONF_FLIPR_ID, DOMAIN, MANUFACTURER
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -84,6 +84,7 @@ class FliprEntity(CoordinatorEntity):
|
|||||||
"""Implements a common class elements representing the Flipr component."""
|
"""Implements a common class elements representing the Flipr component."""
|
||||||
|
|
||||||
_attr_attribution = ATTRIBUTION
|
_attr_attribution = ATTRIBUTION
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coordinator: DataUpdateCoordinator, description: EntityDescription
|
self, coordinator: DataUpdateCoordinator, description: EntityDescription
|
||||||
@ -98,7 +99,5 @@ class FliprEntity(CoordinatorEntity):
|
|||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, flipr_id)},
|
identifiers={(DOMAIN, flipr_id)},
|
||||||
manufacturer=MANUFACTURER,
|
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, ...] = (
|
BINARY_SENSORS_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||||
BinarySensorEntityDescription(
|
BinarySensorEntityDescription(
|
||||||
key="ph_status",
|
key="ph_status",
|
||||||
name="PH Status",
|
translation_key="ph_status",
|
||||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||||
),
|
),
|
||||||
BinarySensorEntityDescription(
|
BinarySensorEntityDescription(
|
||||||
key="chlorine_status",
|
key="chlorine_status",
|
||||||
name="Chlorine Status",
|
translation_key="chlorine_status",
|
||||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -18,39 +18,38 @@ from .const import DOMAIN
|
|||||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="chlorine",
|
key="chlorine",
|
||||||
name="Chlorine",
|
translation_key="chlorine",
|
||||||
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="temperature",
|
key="temperature",
|
||||||
name="Water Temp",
|
translation_key="water_temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="date_time",
|
key="date_time",
|
||||||
name="Last Measured",
|
translation_key="last_measured",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="red_ox",
|
key="red_ox",
|
||||||
name="Red OX",
|
translation_key="red_ox",
|
||||||
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="battery",
|
key="battery",
|
||||||
name="Battery Level",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=SensorDeviceClass.BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
|
@ -26,5 +26,32 @@
|
|||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
"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.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.state == "7.03"
|
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
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
assert state.attributes.get(ATTR_ICON) is None
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTemperature.CELSIUS
|
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.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
|
||||||
assert state.state == "0.23654886"
|
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
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
assert state.attributes.get(ATTR_ICON) is None
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user