Add entity translations for Meater (#95732)

* Add entity translations for Meater

* Update homeassistant/components/meater/sensor.py

---------

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Joost Lekkerkerker 2023-07-03 04:41:46 +02:00 committed by GitHub
parent 4551954c85
commit 792525b7a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 9 deletions

View File

@ -64,8 +64,8 @@ SENSOR_TYPES = (
# Ambient temperature # Ambient temperature
MeaterSensorEntityDescription( MeaterSensorEntityDescription(
key="ambient", key="ambient",
translation_key="ambient",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
name="Ambient",
native_unit_of_measurement=UnitOfTemperature.CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
available=lambda probe: probe is not None, available=lambda probe: probe is not None,
@ -74,8 +74,8 @@ SENSOR_TYPES = (
# Internal temperature (probe tip) # Internal temperature (probe tip)
MeaterSensorEntityDescription( MeaterSensorEntityDescription(
key="internal", key="internal",
translation_key="internal",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
name="Internal",
native_unit_of_measurement=UnitOfTemperature.CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
available=lambda probe: probe is not None, available=lambda probe: probe is not None,
@ -84,7 +84,7 @@ SENSOR_TYPES = (
# Name of selected meat in user language or user given custom name # Name of selected meat in user language or user given custom name
MeaterSensorEntityDescription( MeaterSensorEntityDescription(
key="cook_name", key="cook_name",
name="Cooking", translation_key="cook_name",
available=lambda probe: probe is not None and probe.cook is not None, available=lambda probe: probe is not None and probe.cook is not None,
value=lambda probe: probe.cook.name if probe.cook else None, value=lambda probe: probe.cook.name if probe.cook else None,
), ),
@ -92,15 +92,15 @@ SENSOR_TYPES = (
# Slightly Underdone, Finished, Slightly Overdone, OVERCOOK!. Not translated. # Slightly Underdone, Finished, Slightly Overdone, OVERCOOK!. Not translated.
MeaterSensorEntityDescription( MeaterSensorEntityDescription(
key="cook_state", key="cook_state",
name="Cook state", translation_key="cook_state",
available=lambda probe: probe is not None and probe.cook is not None, available=lambda probe: probe is not None and probe.cook is not None,
value=lambda probe: probe.cook.state if probe.cook else None, value=lambda probe: probe.cook.state if probe.cook else None,
), ),
# Target temperature # Target temperature
MeaterSensorEntityDescription( MeaterSensorEntityDescription(
key="cook_target_temp", key="cook_target_temp",
translation_key="cook_target_temp",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
name="Target",
native_unit_of_measurement=UnitOfTemperature.CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
available=lambda probe: probe is not None and probe.cook is not None, available=lambda probe: probe is not None and probe.cook is not None,
@ -111,8 +111,8 @@ SENSOR_TYPES = (
# Peak temperature # Peak temperature
MeaterSensorEntityDescription( MeaterSensorEntityDescription(
key="cook_peak_temp", key="cook_peak_temp",
translation_key="cook_peak_temp",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
name="Peak",
native_unit_of_measurement=UnitOfTemperature.CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
available=lambda probe: probe is not None and probe.cook is not None, available=lambda probe: probe is not None and probe.cook is not None,
@ -124,8 +124,8 @@ SENSOR_TYPES = (
# Exposed as a TIMESTAMP sensor where the timestamp is current time + remaining time. # Exposed as a TIMESTAMP sensor where the timestamp is current time + remaining time.
MeaterSensorEntityDescription( MeaterSensorEntityDescription(
key="cook_time_remaining", key="cook_time_remaining",
translation_key="cook_time_remaining",
device_class=SensorDeviceClass.TIMESTAMP, device_class=SensorDeviceClass.TIMESTAMP,
name="Remaining time",
available=lambda probe: probe is not None and probe.cook is not None, available=lambda probe: probe is not None and probe.cook is not None,
value=_remaining_time_to_timestamp, value=_remaining_time_to_timestamp,
), ),
@ -133,8 +133,8 @@ SENSOR_TYPES = (
# where the timestamp is current time - elapsed time. # where the timestamp is current time - elapsed time.
MeaterSensorEntityDescription( MeaterSensorEntityDescription(
key="cook_time_elapsed", key="cook_time_elapsed",
translation_key="cook_time_elapsed",
device_class=SensorDeviceClass.TIMESTAMP, device_class=SensorDeviceClass.TIMESTAMP,
name="Elapsed time",
available=lambda probe: probe is not None and probe.cook is not None, available=lambda probe: probe is not None and probe.cook is not None,
value=_elapsed_time_to_timestamp, value=_elapsed_time_to_timestamp,
), ),
@ -192,7 +192,6 @@ class MeaterProbeTemperature(
) -> None: ) -> None:
"""Initialise the sensor.""" """Initialise the sensor."""
super().__init__(coordinator) super().__init__(coordinator)
self._attr_name = f"Meater Probe {description.name}"
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
identifiers={ identifiers={
# Serial numbers are unique identifiers within a specific domain # Serial numbers are unique identifiers within a specific domain

View File

@ -26,5 +26,33 @@
"unknown_auth_error": "[%key:common::config_flow::error::unknown%]", "unknown_auth_error": "[%key:common::config_flow::error::unknown%]",
"service_unavailable_error": "The API is currently unavailable, please try again later." "service_unavailable_error": "The API is currently unavailable, please try again later."
} }
},
"entity": {
"sensor": {
"ambient": {
"name": "Ambient temperature"
},
"internal": {
"name": "Internal temperature"
},
"cook_name": {
"name": "Cooking"
},
"cook_state": {
"name": "Cook state"
},
"cook_target_temp": {
"name": "Target temperature"
},
"cook_peak_temp": {
"name": "Peak temperature"
},
"cook_time_remaining": {
"name": "Time remaining"
},
"cook_time_elapsed": {
"name": "Time elapsed"
}
}
} }
} }