Add entity translations for PureEnergie (#95935)
* Add entity translations for PureEnergie * Fix tests
This commit is contained in:
parent
d1e19c3a85
commit
99430ceb34
3 changed files with 20 additions and 6 deletions
|
@ -39,7 +39,7 @@ class PureEnergieSensorEntityDescription(
|
|||
SENSORS: tuple[PureEnergieSensorEntityDescription, ...] = (
|
||||
PureEnergieSensorEntityDescription(
|
||||
key="power_flow",
|
||||
name="Power Flow",
|
||||
translation_key="power_flow",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -47,7 +47,7 @@ SENSORS: tuple[PureEnergieSensorEntityDescription, ...] = (
|
|||
),
|
||||
PureEnergieSensorEntityDescription(
|
||||
key="energy_consumption_total",
|
||||
name="Energy Consumption",
|
||||
translation_key="energy_consumption_total",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -55,7 +55,7 @@ SENSORS: tuple[PureEnergieSensorEntityDescription, ...] = (
|
|||
),
|
||||
PureEnergieSensorEntityDescription(
|
||||
key="energy_production_total",
|
||||
name="Energy Production",
|
||||
translation_key="energy_production_total",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -83,6 +83,7 @@ class PureEnergieSensorEntity(
|
|||
):
|
||||
"""Defines an Pure Energie sensor."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
entity_description: PureEnergieSensorEntityDescription
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -22,5 +22,18 @@
|
|||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"power_flow": {
|
||||
"name": "Power flow"
|
||||
},
|
||||
"energy_consumption_total": {
|
||||
"name": "Energy consumption"
|
||||
},
|
||||
"energy_production_total": {
|
||||
"name": "Energy production"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ async def test_sensors(
|
|||
assert state
|
||||
assert entry.unique_id == "aabbccddeeff_energy_consumption_total"
|
||||
assert state.state == "17762.1"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Consumption"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "home Energy consumption"
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.KILO_WATT_HOUR
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||
|
@ -46,7 +46,7 @@ async def test_sensors(
|
|||
assert state
|
||||
assert entry.unique_id == "aabbccddeeff_energy_production_total"
|
||||
assert state.state == "21214.6"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Energy Production"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "home Energy production"
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.KILO_WATT_HOUR
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||
|
@ -58,7 +58,7 @@ async def test_sensors(
|
|||
assert state
|
||||
assert entry.unique_id == "aabbccddeeff_power_flow"
|
||||
assert state.state == "338"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Power Flow"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "home Power flow"
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
||||
|
|
Loading…
Add table
Reference in a new issue