Add entity translations to solarlog (#96157)

This commit is contained in:
Joost Lekkerkerker 2023-07-11 20:19:51 +02:00 committed by GitHub
parent fe6402ef73
commit dfad1a920f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 92 additions and 22 deletions

View file

@ -36,13 +36,13 @@ class SolarLogSensorEntityDescription(SensorEntityDescription):
SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
SolarLogSensorEntityDescription(
key="time",
name="last update",
translation_key="last_update",
device_class=SensorDeviceClass.TIMESTAMP,
value=as_local,
),
SolarLogSensorEntityDescription(
key="power_ac",
name="power AC",
translation_key="power_ac",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
@ -50,7 +50,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="power_dc",
name="power DC",
translation_key="power_dc",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
@ -58,21 +58,21 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="voltage_ac",
name="voltage AC",
translation_key="voltage_ac",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
SolarLogSensorEntityDescription(
key="voltage_dc",
name="voltage DC",
translation_key="voltage_dc",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
SolarLogSensorEntityDescription(
key="yield_day",
name="yield day",
translation_key="yield_day",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@ -80,7 +80,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="yield_yesterday",
name="yield yesterday",
translation_key="yield_yesterday",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@ -88,7 +88,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="yield_month",
name="yield month",
translation_key="yield_month",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@ -96,7 +96,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="yield_year",
name="yield year",
translation_key="yield_year",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@ -104,7 +104,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="yield_total",
name="yield total",
translation_key="yield_total",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@ -113,42 +113,42 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="consumption_ac",
name="consumption AC",
translation_key="consumption_ac",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
),
SolarLogSensorEntityDescription(
key="consumption_day",
name="consumption day",
translation_key="consumption_day",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
value=lambda value: round(value / 1000, 3),
),
SolarLogSensorEntityDescription(
key="consumption_yesterday",
name="consumption yesterday",
translation_key="consumption_yesterday",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
value=lambda value: round(value / 1000, 3),
),
SolarLogSensorEntityDescription(
key="consumption_month",
name="consumption month",
translation_key="consumption_month",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
value=lambda value: round(value / 1000, 3),
),
SolarLogSensorEntityDescription(
key="consumption_year",
name="consumption year",
translation_key="consumption_year",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
value=lambda value: round(value / 1000, 3),
),
SolarLogSensorEntityDescription(
key="consumption_total",
name="consumption total",
translation_key="consumption_total",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL,
@ -156,14 +156,14 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="total_power",
name="installed peak power",
translation_key="total_power",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
),
SolarLogSensorEntityDescription(
key="alternator_loss",
name="alternator loss",
translation_key="alternator_loss",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
@ -171,7 +171,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="capacity",
name="capacity",
translation_key="capacity",
icon="mdi:solar-power",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.POWER_FACTOR,
@ -180,7 +180,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="efficiency",
name="efficiency",
translation_key="efficiency",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.POWER_FACTOR,
state_class=SensorStateClass.MEASUREMENT,
@ -188,7 +188,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="power_available",
name="power available",
translation_key="power_available",
icon="mdi:solar-power",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
@ -196,7 +196,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
),
SolarLogSensorEntityDescription(
key="usage",
name="usage",
translation_key="usage",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.POWER_FACTOR,
state_class=SensorStateClass.MEASUREMENT,

View file

@ -16,5 +16,75 @@
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
}
},
"entity": {
"sensor": {
"last_update": {
"name": "Last update"
},
"power_ac": {
"name": "Power AC"
},
"power_dc": {
"name": "Power DC"
},
"voltage_ac": {
"name": "Voltage AC"
},
"voltage_dc": {
"name": "Voltage DC"
},
"yield_day": {
"name": "Yield day"
},
"yield_yesterday": {
"name": "Yield yesterday"
},
"yield_month": {
"name": "Yield month"
},
"yield_year": {
"name": "Yield year"
},
"yield_total": {
"name": "Yield total"
},
"consumption_ac": {
"name": "Consumption AC"
},
"consumption_day": {
"name": "Consumption day"
},
"consumption_yesterday": {
"name": "Consumption yesterday"
},
"consumption_month": {
"name": "Consumption month"
},
"consumption_year": {
"name": "Consumption year"
},
"consumption_total": {
"name": "Consumption total"
},
"total_power": {
"name": "Installed peak power"
},
"alternator_loss": {
"name": "Alternator loss"
},
"capacity": {
"name": "Capacity"
},
"efficiency": {
"name": "Efficiency"
},
"power_available": {
"name": "Power available"
},
"usage": {
"name": "Usage"
}
}
}
}