mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add entity name translations to Tibber (#108797)
This commit is contained in:
parent
3bab1d7cd5
commit
a6c697c80f
@ -64,129 +64,129 @@ PARALLEL_UPDATES = 0
|
|||||||
RT_SENSORS: tuple[SensorEntityDescription, ...] = (
|
RT_SENSORS: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="averagePower",
|
key="averagePower",
|
||||||
name="average power",
|
translation_key="average_power",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
native_unit_of_measurement=UnitOfPower.WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="power",
|
key="power",
|
||||||
name="power",
|
translation_key="power",
|
||||||
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,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="powerProduction",
|
key="powerProduction",
|
||||||
name="power production",
|
translation_key="power_production",
|
||||||
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,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="minPower",
|
key="minPower",
|
||||||
name="min power",
|
translation_key="min_power",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
native_unit_of_measurement=UnitOfPower.WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="maxPower",
|
key="maxPower",
|
||||||
name="max power",
|
translation_key="max_power",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
native_unit_of_measurement=UnitOfPower.WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="accumulatedConsumption",
|
key="accumulatedConsumption",
|
||||||
name="accumulated consumption",
|
translation_key="accumulated_consumption",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="accumulatedConsumptionLastHour",
|
key="accumulatedConsumptionLastHour",
|
||||||
name="accumulated consumption current hour",
|
translation_key="accumulated_consumption_last_hour",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="estimatedHourConsumption",
|
key="estimatedHourConsumption",
|
||||||
name="Estimated consumption current hour",
|
translation_key="estimated_hour_consumption",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="accumulatedProduction",
|
key="accumulatedProduction",
|
||||||
name="accumulated production",
|
translation_key="accumulated_production",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="accumulatedProductionLastHour",
|
key="accumulatedProductionLastHour",
|
||||||
name="accumulated production current hour",
|
translation_key="accumulated_production_last_hour",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="lastMeterConsumption",
|
key="lastMeterConsumption",
|
||||||
name="last meter consumption",
|
translation_key="last_meter_consumption",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="lastMeterProduction",
|
key="lastMeterProduction",
|
||||||
name="last meter production",
|
translation_key="last_meter_production",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="voltagePhase1",
|
key="voltagePhase1",
|
||||||
name="voltage phase1",
|
translation_key="voltage_phase1",
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="voltagePhase2",
|
key="voltagePhase2",
|
||||||
name="voltage phase2",
|
translation_key="voltage_phase2",
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="voltagePhase3",
|
key="voltagePhase3",
|
||||||
name="voltage phase3",
|
translation_key="voltage_phase3",
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="currentL1",
|
key="currentL1",
|
||||||
name="current L1",
|
translation_key="current_l1",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="currentL2",
|
key="currentL2",
|
||||||
name="current L2",
|
translation_key="current_l2",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="currentL3",
|
key="currentL3",
|
||||||
name="current L3",
|
translation_key="current_l3",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="signalStrength",
|
key="signalStrength",
|
||||||
name="signal strength",
|
translation_key="signal_strength",
|
||||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
|
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -194,19 +194,19 @@ RT_SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="accumulatedReward",
|
key="accumulatedReward",
|
||||||
name="accumulated reward",
|
translation_key="accumulated_reward",
|
||||||
device_class=SensorDeviceClass.MONETARY,
|
device_class=SensorDeviceClass.MONETARY,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="accumulatedCost",
|
key="accumulatedCost",
|
||||||
name="accumulated cost",
|
translation_key="accumulated_cost",
|
||||||
device_class=SensorDeviceClass.MONETARY,
|
device_class=SensorDeviceClass.MONETARY,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="powerFactor",
|
key="powerFactor",
|
||||||
name="power factor",
|
translation_key="power_factor",
|
||||||
device_class=SensorDeviceClass.POWER_FACTOR,
|
device_class=SensorDeviceClass.POWER_FACTOR,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -216,23 +216,23 @@ RT_SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||||||
SENSORS: tuple[SensorEntityDescription, ...] = (
|
SENSORS: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="month_cost",
|
key="month_cost",
|
||||||
name="Monthly cost",
|
translation_key="month_cost",
|
||||||
device_class=SensorDeviceClass.MONETARY,
|
device_class=SensorDeviceClass.MONETARY,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="peak_hour",
|
key="peak_hour",
|
||||||
name="Monthly peak hour consumption",
|
translation_key="peak_hour",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="peak_hour_time",
|
key="peak_hour_time",
|
||||||
name="Time of max hour consumption",
|
translation_key="peak_hour_time",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="month_cons",
|
key="month_cons",
|
||||||
name="Monthly net consumption",
|
translation_key="month_cons",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
@ -305,6 +305,8 @@ async def async_setup_entry(
|
|||||||
class TibberSensor(SensorEntity):
|
class TibberSensor(SensorEntity):
|
||||||
"""Representation of a generic Tibber sensor."""
|
"""Representation of a generic Tibber sensor."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, *args: Any, tibber_home: tibber.TibberHome, **kwargs: Any
|
self, *args: Any, tibber_home: tibber.TibberHome, **kwargs: Any
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -335,6 +337,9 @@ class TibberSensor(SensorEntity):
|
|||||||
class TibberSensorElPrice(TibberSensor):
|
class TibberSensorElPrice(TibberSensor):
|
||||||
"""Representation of a Tibber sensor for el price."""
|
"""Representation of a Tibber sensor for el price."""
|
||||||
|
|
||||||
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
|
_attr_translation_key = "electricity_price"
|
||||||
|
|
||||||
def __init__(self, tibber_home: tibber.TibberHome) -> None:
|
def __init__(self, tibber_home: tibber.TibberHome) -> None:
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
super().__init__(tibber_home=tibber_home)
|
super().__init__(tibber_home=tibber_home)
|
||||||
@ -355,8 +360,6 @@ class TibberSensorElPrice(TibberSensor):
|
|||||||
"off_peak_2": None,
|
"off_peak_2": None,
|
||||||
}
|
}
|
||||||
self._attr_icon = ICON
|
self._attr_icon = ICON
|
||||||
self._attr_name = f"Electricity price {self._home_name}"
|
|
||||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
|
||||||
self._attr_unique_id = self._tibber_home.home_id
|
self._attr_unique_id = self._tibber_home.home_id
|
||||||
self._model = "Price Sensor"
|
self._model = "Price Sensor"
|
||||||
|
|
||||||
@ -424,7 +427,6 @@ class TibberDataSensor(TibberSensor, CoordinatorEntity["TibberDataCoordinator"])
|
|||||||
self._attr_unique_id = (
|
self._attr_unique_id = (
|
||||||
f"{self._tibber_home.home_id}_{self.entity_description.key}"
|
f"{self._tibber_home.home_id}_{self.entity_description.key}"
|
||||||
)
|
)
|
||||||
self._attr_name = f"{entity_description.name} {self._home_name}"
|
|
||||||
if entity_description.key == "month_cost":
|
if entity_description.key == "month_cost":
|
||||||
self._attr_native_unit_of_measurement = self._tibber_home.currency
|
self._attr_native_unit_of_measurement = self._tibber_home.currency
|
||||||
|
|
||||||
@ -452,7 +454,6 @@ class TibberSensorRT(TibberSensor, CoordinatorEntity["TibberRtDataCoordinator"])
|
|||||||
self._model = "Tibber Pulse"
|
self._model = "Tibber Pulse"
|
||||||
self._device_name = f"{self._model} {self._home_name}"
|
self._device_name = f"{self._model} {self._home_name}"
|
||||||
|
|
||||||
self._attr_name = f"{description.name} {self._home_name}"
|
|
||||||
self._attr_native_value = initial_state
|
self._attr_native_value = initial_state
|
||||||
self._attr_unique_id = f"{self._tibber_home.home_id}_rt_{description.name}"
|
self._attr_unique_id = f"{self._tibber_home.home_id}_rt_{description.name}"
|
||||||
|
|
||||||
|
@ -1,4 +1,89 @@
|
|||||||
{
|
{
|
||||||
|
"entity": {
|
||||||
|
"sensor": {
|
||||||
|
"electricity_price": {
|
||||||
|
"name": "Electricity price"
|
||||||
|
},
|
||||||
|
"month_cost": {
|
||||||
|
"name": "Monthly cost"
|
||||||
|
},
|
||||||
|
"peak_hour": {
|
||||||
|
"name": "Monthly peak hour consumption"
|
||||||
|
},
|
||||||
|
"peak_hour_time": {
|
||||||
|
"name": "Time of max hour consumption"
|
||||||
|
},
|
||||||
|
"month_cons": {
|
||||||
|
"name": "Monthly net consumption"
|
||||||
|
},
|
||||||
|
"average_power": {
|
||||||
|
"name": "Average power"
|
||||||
|
},
|
||||||
|
"power": {
|
||||||
|
"name": "Power"
|
||||||
|
},
|
||||||
|
"power_production": {
|
||||||
|
"name": "Power production"
|
||||||
|
},
|
||||||
|
"min_power": {
|
||||||
|
"name": "Min power"
|
||||||
|
},
|
||||||
|
"max_power": {
|
||||||
|
"name": "Max power"
|
||||||
|
},
|
||||||
|
"accumulated_consumption": {
|
||||||
|
"name": "Accumulated consumption"
|
||||||
|
},
|
||||||
|
"accumulated_consumption_last_hour": {
|
||||||
|
"name": "Accumulated consumption current hour"
|
||||||
|
},
|
||||||
|
"estimated_hour_consumption": {
|
||||||
|
"name": "Estimated consumption current hour"
|
||||||
|
},
|
||||||
|
"accumulated_production": {
|
||||||
|
"name": "Accumulated production"
|
||||||
|
},
|
||||||
|
"accumulated_production_last_hour": {
|
||||||
|
"name": "Accumulated production current hour"
|
||||||
|
},
|
||||||
|
"last_meter_consumption": {
|
||||||
|
"name": "Last meter consumption"
|
||||||
|
},
|
||||||
|
"last_meter_production": {
|
||||||
|
"name": "Last meter production"
|
||||||
|
},
|
||||||
|
"voltage_phase1": {
|
||||||
|
"name": "Voltage phase1"
|
||||||
|
},
|
||||||
|
"voltage_phase2": {
|
||||||
|
"name": "Voltage phase2"
|
||||||
|
},
|
||||||
|
"voltage_phase3": {
|
||||||
|
"name": "Voltage phase3"
|
||||||
|
},
|
||||||
|
"current_l1": {
|
||||||
|
"name": "Current L1"
|
||||||
|
},
|
||||||
|
"current_l2": {
|
||||||
|
"name": "Current L2"
|
||||||
|
},
|
||||||
|
"current_l3": {
|
||||||
|
"name": "Current L3"
|
||||||
|
},
|
||||||
|
"signal_strength": {
|
||||||
|
"name": "Signal strength"
|
||||||
|
},
|
||||||
|
"accumulated_reward": {
|
||||||
|
"name": "Accumulated reward"
|
||||||
|
},
|
||||||
|
"accumulated_cost": {
|
||||||
|
"name": "Accumulated cost"
|
||||||
|
},
|
||||||
|
"power_factor": {
|
||||||
|
"name": "Power factor"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user