Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions homeassistant/components/pure_energie/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ 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,
value_fn=lambda data: data.smartbridge.power_flow,
),
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,
value_fn=lambda data: data.smartbridge.energy_consumption_total,
),
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,
Expand Down Expand Up @@ -83,6 +83,7 @@ class PureEnergieSensorEntity(
):
"""Defines an Pure Energie sensor."""

_attr_has_entity_name = True
entity_description: PureEnergieSensorEntityDescription

def __init__(
Expand Down
13 changes: 13 additions & 0 deletions homeassistant/components/pure_energie/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
6 changes: 3 additions & 3 deletions tests/components/pure_energie/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down