Add entity translations for EasyEnergy (#95235)

This commit is contained in:
Joost Lekkerkerker 2023-06-26 14:17:15 +02:00 committed by GitHub
parent d14f04eb7e
commit 5a98155700
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 21 deletions

View File

@ -48,7 +48,7 @@ class EasyEnergySensorEntityDescription(
SENSORS: tuple[EasyEnergySensorEntityDescription, ...] = (
EasyEnergySensorEntityDescription(
key="current_hour_price",
name="Current hour",
translation_key="current_hour_price",
service_type="today_gas",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfVolume.CUBIC_METERS}",
@ -56,14 +56,14 @@ SENSORS: tuple[EasyEnergySensorEntityDescription, ...] = (
),
EasyEnergySensorEntityDescription(
key="next_hour_price",
name="Next hour",
translation_key="next_hour_price",
service_type="today_gas",
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfVolume.CUBIC_METERS}",
value_fn=lambda data: get_gas_price(data, 1),
),
EasyEnergySensorEntityDescription(
key="current_hour_price",
name="Current hour",
translation_key="current_hour_price",
service_type="today_energy_usage",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
@ -71,7 +71,7 @@ SENSORS: tuple[EasyEnergySensorEntityDescription, ...] = (
),
EasyEnergySensorEntityDescription(
key="next_hour_price",
name="Next hour",
translation_key="next_hour_price",
service_type="today_energy_usage",
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
value_fn=lambda data: data.energy_today.price_at_time(
@ -80,42 +80,42 @@ SENSORS: tuple[EasyEnergySensorEntityDescription, ...] = (
),
EasyEnergySensorEntityDescription(
key="average_price",
name="Average - today",
translation_key="average_price",
service_type="today_energy_usage",
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
value_fn=lambda data: data.energy_today.average_usage_price,
),
EasyEnergySensorEntityDescription(
key="max_price",
name="Highest price - today",
translation_key="max_price",
service_type="today_energy_usage",
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
value_fn=lambda data: data.energy_today.extreme_usage_prices[1],
),
EasyEnergySensorEntityDescription(
key="min_price",
name="Lowest price - today",
translation_key="min_price",
service_type="today_energy_usage",
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
value_fn=lambda data: data.energy_today.extreme_usage_prices[0],
),
EasyEnergySensorEntityDescription(
key="highest_price_time",
name="Time of highest price - today",
translation_key="highest_price_time",
service_type="today_energy_usage",
device_class=SensorDeviceClass.TIMESTAMP,
value_fn=lambda data: data.energy_today.highest_usage_price_time,
),
EasyEnergySensorEntityDescription(
key="lowest_price_time",
name="Time of lowest price - today",
translation_key="lowest_price_time",
service_type="today_energy_usage",
device_class=SensorDeviceClass.TIMESTAMP,
value_fn=lambda data: data.energy_today.lowest_usage_price_time,
),
EasyEnergySensorEntityDescription(
key="percentage_of_max",
name="Current percentage of highest price - today",
translation_key="percentage_of_max",
service_type="today_energy_usage",
native_unit_of_measurement=PERCENTAGE,
icon="mdi:percent",
@ -123,7 +123,7 @@ SENSORS: tuple[EasyEnergySensorEntityDescription, ...] = (
),
EasyEnergySensorEntityDescription(
key="current_hour_price",
name="Current hour",
translation_key="current_hour_price",
service_type="today_energy_return",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
@ -131,7 +131,7 @@ SENSORS: tuple[EasyEnergySensorEntityDescription, ...] = (
),
EasyEnergySensorEntityDescription(
key="next_hour_price",
name="Next hour",
translation_key="next_hour_price",
service_type="today_energy_return",
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
value_fn=lambda data: data.energy_today.price_at_time(
@ -140,42 +140,42 @@ SENSORS: tuple[EasyEnergySensorEntityDescription, ...] = (
),
EasyEnergySensorEntityDescription(
key="average_price",
name="Average - today",
translation_key="average_price",
service_type="today_energy_return",
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
value_fn=lambda data: data.energy_today.average_return_price,
),
EasyEnergySensorEntityDescription(
key="max_price",
name="Highest price - today",
translation_key="max_price",
service_type="today_energy_return",
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
value_fn=lambda data: data.energy_today.extreme_return_prices[1],
),
EasyEnergySensorEntityDescription(
key="min_price",
name="Lowest price - today",
translation_key="min_price",
service_type="today_energy_return",
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
value_fn=lambda data: data.energy_today.extreme_return_prices[0],
),
EasyEnergySensorEntityDescription(
key="highest_price_time",
name="Time of highest price - today",
translation_key="highest_price_time",
service_type="today_energy_return",
device_class=SensorDeviceClass.TIMESTAMP,
value_fn=lambda data: data.energy_today.highest_return_price_time,
),
EasyEnergySensorEntityDescription(
key="lowest_price_time",
name="Time of lowest price - today",
translation_key="lowest_price_time",
service_type="today_energy_return",
device_class=SensorDeviceClass.TIMESTAMP,
value_fn=lambda data: data.energy_today.lowest_return_price_time,
),
EasyEnergySensorEntityDescription(
key="percentage_of_max",
name="Current percentage of highest price - today",
translation_key="percentage_of_max",
service_type="today_energy_return",
native_unit_of_measurement=PERCENTAGE,
icon="mdi:percent",
@ -183,7 +183,7 @@ SENSORS: tuple[EasyEnergySensorEntityDescription, ...] = (
),
EasyEnergySensorEntityDescription(
key="hours_priced_equal_or_lower",
name="Hours priced equal or lower than current - today",
translation_key="hours_priced_equal_or_lower",
service_type="today_energy_usage",
native_unit_of_measurement=UnitOfTime.HOURS,
icon="mdi:clock",
@ -191,7 +191,7 @@ SENSORS: tuple[EasyEnergySensorEntityDescription, ...] = (
),
EasyEnergySensorEntityDescription(
key="hours_priced_equal_or_higher",
name="Hours priced equal or higher than current - today",
translation_key="hours_priced_equal_or_higher",
service_type="today_energy_return",
native_unit_of_measurement=UnitOfTime.HOURS,
icon="mdi:clock",
@ -231,7 +231,7 @@ async def async_setup_entry(
class EasyEnergySensorEntity(
CoordinatorEntity[EasyEnergyDataUpdateCoordinator], SensorEntity
):
"""Defines a easyEnergy sensor."""
"""Defines an easyEnergy sensor."""
_attr_has_entity_name = True
_attr_attribution = "Data provided by easyEnergy"

View File

@ -8,5 +8,39 @@
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
}
},
"entity": {
"sensor": {
"current_hour_price": {
"name": "Current hour"
},
"next_hour_price": {
"name": "Next hour"
},
"average_price": {
"name": "Average - today"
},
"max_price": {
"name": "Highest price - today"
},
"min_price": {
"name": "Lowest price - today"
},
"highest_price_time": {
"name": "Time of highest price - today"
},
"lowest_price_time": {
"name": "Time of lowest price - today"
},
"percentage_of_max": {
"name": "Current percentage of highest price - today"
},
"hours_priced_equal_or_lower": {
"name": "Hours priced equal or lower than current - today"
},
"hours_priced_equal_or_higher": {
"name": "Hours priced equal or higher than current - today"
}
}
}
}