Add translations for youless sensors (#136349)

This commit is contained in:
Gerben Jongerius 2025-01-28 11:29:29 +01:00 committed by GitHub
parent edac4b83d9
commit 164078ac69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 719 additions and 700 deletions

View File

@ -20,6 +20,6 @@ class YouLessEntity(CoordinatorEntity[YouLessCoordinator]):
identifiers={(DOMAIN, device_group)}, identifiers={(DOMAIN, device_group)},
manufacturer="YouLess", manufacturer="YouLess",
model=self.device.model, model=self.device.model,
name=device_name, translation_key=device_name,
sw_version=self.device.firmware_version, sw_version=self.device.firmware_version,
) )

View File

@ -36,7 +36,6 @@ class YouLessSensorEntityDescription(SensorEntityDescription):
"""Describes a YouLess sensor entity.""" """Describes a YouLess sensor entity."""
device_group: str device_group: str
device_group_name: str
value_func: Callable[[YoulessAPI], float | None] value_func: Callable[[YoulessAPI], float | None]
@ -44,9 +43,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="water", key="water",
device_group="water", device_group="water",
device_group_name="Water meter", translation_key="total_water",
name="Water usage",
icon="mdi:water",
device_class=SensorDeviceClass.WATER, device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
@ -57,9 +54,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="gas", key="gas",
device_group="gas", device_group="gas",
device_group_name="Gas meter", translation_key="total_gas_m3",
name="Gas usage",
icon="mdi:fire",
device_class=SensorDeviceClass.GAS, device_class=SensorDeviceClass.GAS,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
@ -68,9 +63,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="usage", key="usage",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_power_w",
name="Power Usage",
icon="mdi:meter-electric",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT, native_unit_of_measurement=UnitOfPower.WATT,
@ -83,9 +76,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="power_low", key="power_low",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="total_energy_import_tariff_kwh",
name="Energy low", translation_placeholders={"tariff": "1"},
icon="mdi:transmission-tower-export",
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
@ -96,9 +88,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="power_high", key="power_high",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="total_energy_import_tariff_kwh",
name="Energy high", translation_placeholders={"tariff": "2"},
icon="mdi:transmission-tower-export",
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
@ -109,9 +100,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="power_total", key="power_total",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="total_energy_import_kwh",
name="Energy total",
icon="mdi:transmission-tower-export",
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL, state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
@ -124,9 +113,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="phase_1_power", key="phase_1_power",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_power_phase_w",
name="Phase 1 power", translation_placeholders={"phase": "1"},
icon=None,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT, native_unit_of_measurement=UnitOfPower.WATT,
@ -135,9 +123,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="phase_1_voltage", key="phase_1_voltage",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_voltage_phase_v",
name="Phase 1 voltage", translation_placeholders={"phase": "1"},
icon=None,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricPotential.VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
@ -148,9 +135,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="phase_1_current", key="phase_1_current",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_current_phase_a",
name="Phase 1 current", translation_placeholders={"phase": "1"},
icon=None,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
@ -161,9 +147,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="phase_2_power", key="phase_2_power",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_power_phase_w",
name="Phase 2 power", translation_placeholders={"phase": "2"},
icon=None,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT, native_unit_of_measurement=UnitOfPower.WATT,
@ -172,9 +157,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="phase_2_voltage", key="phase_2_voltage",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_voltage_phase_v",
name="Phase 2 voltage", translation_placeholders={"phase": "2"},
icon=None,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricPotential.VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
@ -185,9 +169,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="phase_2_current", key="phase_2_current",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_current_phase_a",
name="Phase 2 current", translation_placeholders={"phase": "2"},
icon=None,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
@ -198,9 +181,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="phase_3_power", key="phase_3_power",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_power_phase_w",
name="Phase 3 power", translation_placeholders={"phase": "3"},
icon=None,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT, native_unit_of_measurement=UnitOfPower.WATT,
@ -209,9 +191,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="phase_3_voltage", key="phase_3_voltage",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_voltage_phase_v",
name="Phase 3 voltage", translation_placeholders={"phase": "3"},
icon=None,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricPotential.VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
@ -222,9 +203,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="phase_3_current", key="phase_3_current",
device_group="power", device_group="power",
device_group_name="Power usage", translation_key="active_current_phase_a",
name="Phase 3 current", translation_placeholders={"phase": "3"},
icon=None,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
@ -235,9 +215,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="delivery_low", key="delivery_low",
device_group="delivery", device_group="delivery",
device_group_name="Energy delivery", translation_key="total_energy_export_tariff_kwh",
name="Energy delivery low", translation_placeholders={"tariff": "1"},
icon="mdi:transmission-tower-import",
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
@ -250,9 +229,8 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="delivery_high", key="delivery_high",
device_group="delivery", device_group="delivery",
device_group_name="Energy delivery", translation_key="total_energy_export_tariff_kwh",
name="Energy delivery high", translation_placeholders={"tariff": "2"},
icon="mdi:transmission-tower-import",
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
@ -265,9 +243,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="extra_total", key="extra_total",
device_group="extra", device_group="extra",
device_group_name="Extra meter", translation_key="total_s0_kwh",
name="Extra total",
icon="mdi:meter-electric",
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
@ -280,9 +256,7 @@ SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
YouLessSensorEntityDescription( YouLessSensorEntityDescription(
key="extra_usage", key="extra_usage",
device_group="extra", device_group="extra",
device_group_name="Extra meter", translation_key="active_s0_w",
name="Extra usage",
icon="mdi:lightning-bolt",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.WATT, native_unit_of_measurement=UnitOfPower.WATT,
@ -316,6 +290,7 @@ class YouLessSensor(YouLessEntity, SensorEntity):
"""Representation of a Sensor.""" """Representation of a Sensor."""
entity_description: YouLessSensorEntityDescription entity_description: YouLessSensorEntityDescription
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
@ -327,7 +302,7 @@ class YouLessSensor(YouLessEntity, SensorEntity):
super().__init__( super().__init__(
coordinator, coordinator,
f"{device}_{description.device_group}", f"{device}_{description.device_group}",
description.device_group_name, description.device_group,
) )
self._attr_unique_id = f"{DOMAIN}_{device}_{description.key}" self._attr_unique_id = f"{DOMAIN}_{device}_{description.key}"
self.entity_description = description self.entity_description = description

View File

@ -14,5 +14,59 @@
"error": { "error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" "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