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

View File

@ -16,5 +16,75 @@
"abort": { "abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]" "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"
}
}
} }
} }