mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add translations for youless sensors (#136349)
This commit is contained in:
parent
edac4b83d9
commit
164078ac69
@ -20,6 +20,6 @@ class YouLessEntity(CoordinatorEntity[YouLessCoordinator]):
|
||||
identifiers={(DOMAIN, device_group)},
|
||||
manufacturer="YouLess",
|
||||
model=self.device.model,
|
||||
name=device_name,
|
||||
translation_key=device_name,
|
||||
sw_version=self.device.firmware_version,
|
||||
)
|
||||
|
@ -36,7 +36,6 @@ class YouLessSensorEntityDescription(SensorEntityDescription):
|
||||
"""Describes a YouLess sensor entity."""
|
||||
|
||||
device_group: str
|
||||
device_group_name: str
|
||||
value_func: Callable[[YoulessAPI], float | None]
|
||||
|
||||
|
||||
@ -44,9 +43,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="water",
|
||||
device_group="water",
|
||||
device_group_name="Water meter",
|
||||
name="Water usage",
|
||||
icon="mdi:water",
|
||||
translation_key="total_water",
|
||||
device_class=SensorDeviceClass.WATER,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||
@ -57,9 +54,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="gas",
|
||||
device_group="gas",
|
||||
device_group_name="Gas meter",
|
||||
name="Gas usage",
|
||||
icon="mdi:fire",
|
||||
translation_key="total_gas_m3",
|
||||
device_class=SensorDeviceClass.GAS,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||
@ -68,9 +63,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="usage",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Power Usage",
|
||||
icon="mdi:meter-electric",
|
||||
translation_key="active_power_w",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@ -83,9 +76,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="power_low",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Energy low",
|
||||
icon="mdi:transmission-tower-export",
|
||||
translation_key="total_energy_import_tariff_kwh",
|
||||
translation_placeholders={"tariff": "1"},
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@ -96,9 +88,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="power_high",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Energy high",
|
||||
icon="mdi:transmission-tower-export",
|
||||
translation_key="total_energy_import_tariff_kwh",
|
||||
translation_placeholders={"tariff": "2"},
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@ -109,9 +100,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="power_total",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Energy total",
|
||||
icon="mdi:transmission-tower-export",
|
||||
translation_key="total_energy_import_kwh",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@ -124,9 +113,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="phase_1_power",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Phase 1 power",
|
||||
icon=None,
|
||||
translation_key="active_power_phase_w",
|
||||
translation_placeholders={"phase": "1"},
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@ -135,9 +123,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="phase_1_voltage",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Phase 1 voltage",
|
||||
icon=None,
|
||||
translation_key="active_voltage_phase_v",
|
||||
translation_placeholders={"phase": "1"},
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@ -148,9 +135,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="phase_1_current",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Phase 1 current",
|
||||
icon=None,
|
||||
translation_key="active_current_phase_a",
|
||||
translation_placeholders={"phase": "1"},
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@ -161,9 +147,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="phase_2_power",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Phase 2 power",
|
||||
icon=None,
|
||||
translation_key="active_power_phase_w",
|
||||
translation_placeholders={"phase": "2"},
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@ -172,9 +157,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="phase_2_voltage",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Phase 2 voltage",
|
||||
icon=None,
|
||||
translation_key="active_voltage_phase_v",
|
||||
translation_placeholders={"phase": "2"},
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@ -185,9 +169,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="phase_2_current",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Phase 2 current",
|
||||
icon=None,
|
||||
translation_key="active_current_phase_a",
|
||||
translation_placeholders={"phase": "2"},
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@ -198,9 +181,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="phase_3_power",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Phase 3 power",
|
||||
icon=None,
|
||||
translation_key="active_power_phase_w",
|
||||
translation_placeholders={"phase": "3"},
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@ -209,9 +191,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="phase_3_voltage",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Phase 3 voltage",
|
||||
icon=None,
|
||||
translation_key="active_voltage_phase_v",
|
||||
translation_placeholders={"phase": "3"},
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@ -222,9 +203,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="phase_3_current",
|
||||
device_group="power",
|
||||
device_group_name="Power usage",
|
||||
name="Phase 3 current",
|
||||
icon=None,
|
||||
translation_key="active_current_phase_a",
|
||||
translation_placeholders={"phase": "3"},
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@ -235,9 +215,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="delivery_low",
|
||||
device_group="delivery",
|
||||
device_group_name="Energy delivery",
|
||||
name="Energy delivery low",
|
||||
icon="mdi:transmission-tower-import",
|
||||
translation_key="total_energy_export_tariff_kwh",
|
||||
translation_placeholders={"tariff": "1"},
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@ -250,9 +229,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="delivery_high",
|
||||
device_group="delivery",
|
||||
device_group_name="Energy delivery",
|
||||
name="Energy delivery high",
|
||||
icon="mdi:transmission-tower-import",
|
||||
translation_key="total_energy_export_tariff_kwh",
|
||||
translation_placeholders={"tariff": "2"},
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@ -265,9 +243,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="extra_total",
|
||||
device_group="extra",
|
||||
device_group_name="Extra meter",
|
||||
name="Extra total",
|
||||
icon="mdi:meter-electric",
|
||||
translation_key="total_s0_kwh",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@ -280,9 +256,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
YouLessSensorEntityDescription(
|
||||
key="extra_usage",
|
||||
device_group="extra",
|
||||
device_group_name="Extra meter",
|
||||
name="Extra usage",
|
||||
icon="mdi:lightning-bolt",
|
||||
translation_key="active_s0_w",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@ -316,6 +290,7 @@ class YouLessSensor(YouLessEntity, SensorEntity):
|
||||
"""Representation of a Sensor."""
|
||||
|
||||
entity_description: YouLessSensorEntityDescription
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -327,7 +302,7 @@ class YouLessSensor(YouLessEntity, SensorEntity):
|
||||
super().__init__(
|
||||
coordinator,
|
||||
f"{device}_{description.device_group}",
|
||||
description.device_group_name,
|
||||
description.device_group,
|
||||
)
|
||||
self._attr_unique_id = f"{DOMAIN}_{device}_{description.key}"
|
||||
self.entity_description = description
|
||||
|
@ -14,5 +14,59 @@
|
||||
"error": {
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
}
|
||||
},
|
||||
"device": {
|
||||
"water": {
|
||||
"name": "Water meter"
|
||||
},
|
||||
"gas": {
|
||||
"name": "Gas meter"
|
||||
},
|
||||
"power": {
|
||||
"name": "Power meter"
|
||||
},
|
||||
"delivery": {
|
||||
"name": "Energy delivery meter"
|
||||
},
|
||||
"extra": {
|
||||
"name": "S0 meter"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"total_water": {
|
||||
"name": "Total water usage"
|
||||
},
|
||||
"total_gas_m3": {
|
||||
"name": "Total gas usage"
|
||||
},
|
||||
"active_power_w": {
|
||||
"name": "Current power usage"
|
||||
},
|
||||
"active_power_phase_w": {
|
||||
"name": "Power phase {phase}"
|
||||
},
|
||||
"active_voltage_phase_v": {
|
||||
"name": "Voltage phase {phase}"
|
||||
},
|
||||
"active_current_phase_a": {
|
||||
"name": "Current phase {phase}"
|
||||
},
|
||||
"total_energy_import_tariff_kwh": {
|
||||
"name": "Energy import tariff {tariff}"
|
||||
},
|
||||
"total_energy_import_kwh": {
|
||||
"name": "Total energy import"
|
||||
},
|
||||
"total_energy_export_tariff_kwh": {
|
||||
"name": "Energy export tariff {tariff}"
|
||||
},
|
||||
"total_s0_kwh": {
|
||||
"name": "Total energy"
|
||||
},
|
||||
"active_s0_w": {
|
||||
"name": "Current usage"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user