Add entity translations to OVO Energy (#98835)
This commit is contained in:
parent
afc3899a1b
commit
b65e3ddc99
3 changed files with 38 additions and 8 deletions
|
@ -98,6 +98,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
class OVOEnergyEntity(CoordinatorEntity[DataUpdateCoordinator[OVODailyUsage]]):
|
class OVOEnergyEntity(CoordinatorEntity[DataUpdateCoordinator[OVODailyUsage]]):
|
||||||
"""Defines a base OVO Energy entity."""
|
"""Defines a base OVO Energy entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: DataUpdateCoordinator[OVODailyUsage],
|
coordinator: DataUpdateCoordinator[OVODailyUsage],
|
||||||
|
|
|
@ -43,7 +43,7 @@ class OVOEnergySensorEntityDescription(SensorEntityDescription):
|
||||||
SENSOR_TYPES_ELECTRICITY: tuple[OVOEnergySensorEntityDescription, ...] = (
|
SENSOR_TYPES_ELECTRICITY: tuple[OVOEnergySensorEntityDescription, ...] = (
|
||||||
OVOEnergySensorEntityDescription(
|
OVOEnergySensorEntityDescription(
|
||||||
key="last_electricity_reading",
|
key="last_electricity_reading",
|
||||||
name="OVO Last Electricity Reading",
|
translation_key="last_electricity_reading",
|
||||||
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,
|
||||||
|
@ -51,7 +51,7 @@ SENSOR_TYPES_ELECTRICITY: tuple[OVOEnergySensorEntityDescription, ...] = (
|
||||||
),
|
),
|
||||||
OVOEnergySensorEntityDescription(
|
OVOEnergySensorEntityDescription(
|
||||||
key=KEY_LAST_ELECTRICITY_COST,
|
key=KEY_LAST_ELECTRICITY_COST,
|
||||||
name="OVO Last Electricity Cost",
|
translation_key=KEY_LAST_ELECTRICITY_COST,
|
||||||
device_class=SensorDeviceClass.MONETARY,
|
device_class=SensorDeviceClass.MONETARY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
value=lambda usage: usage.electricity[-1].cost.amount
|
value=lambda usage: usage.electricity[-1].cost.amount
|
||||||
|
@ -60,14 +60,14 @@ SENSOR_TYPES_ELECTRICITY: tuple[OVOEnergySensorEntityDescription, ...] = (
|
||||||
),
|
),
|
||||||
OVOEnergySensorEntityDescription(
|
OVOEnergySensorEntityDescription(
|
||||||
key="last_electricity_start_time",
|
key="last_electricity_start_time",
|
||||||
name="OVO Last Electricity Start Time",
|
translation_key="last_electricity_start_time",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
value=lambda usage: dt_util.as_utc(usage.electricity[-1].interval.start),
|
value=lambda usage: dt_util.as_utc(usage.electricity[-1].interval.start),
|
||||||
),
|
),
|
||||||
OVOEnergySensorEntityDescription(
|
OVOEnergySensorEntityDescription(
|
||||||
key="last_electricity_end_time",
|
key="last_electricity_end_time",
|
||||||
name="OVO Last Electricity End Time",
|
translation_key="last_electricity_end_time",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
value=lambda usage: dt_util.as_utc(usage.electricity[-1].interval.end),
|
value=lambda usage: dt_util.as_utc(usage.electricity[-1].interval.end),
|
||||||
|
@ -77,7 +77,7 @@ SENSOR_TYPES_ELECTRICITY: tuple[OVOEnergySensorEntityDescription, ...] = (
|
||||||
SENSOR_TYPES_GAS: tuple[OVOEnergySensorEntityDescription, ...] = (
|
SENSOR_TYPES_GAS: tuple[OVOEnergySensorEntityDescription, ...] = (
|
||||||
OVOEnergySensorEntityDescription(
|
OVOEnergySensorEntityDescription(
|
||||||
key="last_gas_reading",
|
key="last_gas_reading",
|
||||||
name="OVO Last Gas Reading",
|
translation_key="last_gas_reading",
|
||||||
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,
|
||||||
|
@ -86,7 +86,7 @@ SENSOR_TYPES_GAS: tuple[OVOEnergySensorEntityDescription, ...] = (
|
||||||
),
|
),
|
||||||
OVOEnergySensorEntityDescription(
|
OVOEnergySensorEntityDescription(
|
||||||
key=KEY_LAST_GAS_COST,
|
key=KEY_LAST_GAS_COST,
|
||||||
name="OVO Last Gas Cost",
|
translation_key=KEY_LAST_GAS_COST,
|
||||||
device_class=SensorDeviceClass.MONETARY,
|
device_class=SensorDeviceClass.MONETARY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
icon="mdi:cash-multiple",
|
icon="mdi:cash-multiple",
|
||||||
|
@ -96,14 +96,14 @@ SENSOR_TYPES_GAS: tuple[OVOEnergySensorEntityDescription, ...] = (
|
||||||
),
|
),
|
||||||
OVOEnergySensorEntityDescription(
|
OVOEnergySensorEntityDescription(
|
||||||
key="last_gas_start_time",
|
key="last_gas_start_time",
|
||||||
name="OVO Last Gas Start Time",
|
translation_key="last_gas_start_time",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
value=lambda usage: dt_util.as_utc(usage.gas[-1].interval.start),
|
value=lambda usage: dt_util.as_utc(usage.gas[-1].interval.start),
|
||||||
),
|
),
|
||||||
OVOEnergySensorEntityDescription(
|
OVOEnergySensorEntityDescription(
|
||||||
key="last_gas_end_time",
|
key="last_gas_end_time",
|
||||||
name="OVO Last Gas End Time",
|
translation_key="last_gas_end_time",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
value=lambda usage: dt_util.as_utc(usage.gas[-1].interval.end),
|
value=lambda usage: dt_util.as_utc(usage.gas[-1].interval.end),
|
||||||
|
|
|
@ -24,5 +24,33 @@
|
||||||
"title": "Reauthentication"
|
"title": "Reauthentication"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"sensor": {
|
||||||
|
"last_electricity_reading": {
|
||||||
|
"name": "Last electricity reading"
|
||||||
|
},
|
||||||
|
"last_electricity_cost": {
|
||||||
|
"name": "Last electricity cost"
|
||||||
|
},
|
||||||
|
"last_electricity_start_time": {
|
||||||
|
"name": "Last electricity start time"
|
||||||
|
},
|
||||||
|
"last_electricity_end_time": {
|
||||||
|
"name": "Last electricity end time"
|
||||||
|
},
|
||||||
|
"last_gas_reading": {
|
||||||
|
"name": "Last gas reading"
|
||||||
|
},
|
||||||
|
"last_gas_cost": {
|
||||||
|
"name": "Last gas cost"
|
||||||
|
},
|
||||||
|
"last_gas_start_time": {
|
||||||
|
"name": "Last gas start time"
|
||||||
|
},
|
||||||
|
"last_gas_end_time": {
|
||||||
|
"name": "Last gas end time"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue