mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
Make EnergyZero electricity sensor semantics interval-neutral (#181492)
This commit is contained in:
@@ -12,13 +12,7 @@ from homeassistant.components.sensor import (
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CURRENCY_EURO,
|
||||
PERCENTAGE,
|
||||
UnitOfEnergy,
|
||||
UnitOfTime,
|
||||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.const import CURRENCY_EURO, PERCENTAGE, UnitOfEnergy, UnitOfVolume
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
@@ -60,7 +54,7 @@ SENSORS: tuple[EnergyZeroSensorEntityDescription, ...] = (
|
||||
),
|
||||
EnergyZeroSensorEntityDescription(
|
||||
key="current_hour_price",
|
||||
translation_key="current_hour_price",
|
||||
translation_key="current_price",
|
||||
service_type="today_energy",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||
@@ -69,7 +63,7 @@ SENSORS: tuple[EnergyZeroSensorEntityDescription, ...] = (
|
||||
),
|
||||
EnergyZeroSensorEntityDescription(
|
||||
key="next_hour_price",
|
||||
translation_key="next_hour_price",
|
||||
translation_key="next_price",
|
||||
service_type="today_energy",
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||
suggested_display_precision=3,
|
||||
@@ -128,7 +122,6 @@ SENSORS: tuple[EnergyZeroSensorEntityDescription, ...] = (
|
||||
key="hours_priced_equal_or_lower",
|
||||
translation_key="hours_priced_equal_or_lower",
|
||||
service_type="today_energy",
|
||||
native_unit_of_measurement=UnitOfTime.HOURS,
|
||||
value_fn=lambda data: data.energy_today.time_ranges_priced_equal_or_lower,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -17,11 +17,14 @@
|
||||
"current_hour_price": {
|
||||
"name": "Current hour"
|
||||
},
|
||||
"current_price": {
|
||||
"name": "Current price"
|
||||
},
|
||||
"highest_price_time": {
|
||||
"name": "Time of highest price - today"
|
||||
},
|
||||
"hours_priced_equal_or_lower": {
|
||||
"name": "Hours priced equal or lower than current - today"
|
||||
"name": "Periods priced equal or lower"
|
||||
},
|
||||
"lowest_price_time": {
|
||||
"name": "Time of lowest price - today"
|
||||
@@ -35,6 +38,9 @@
|
||||
"next_hour_price": {
|
||||
"name": "Next hour"
|
||||
},
|
||||
"next_price": {
|
||||
"name": "Next price"
|
||||
},
|
||||
"percentage_of_max": {
|
||||
"name": "Current percentage of highest price - today"
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Current hour',
|
||||
'original_name': 'Current price',
|
||||
'platform': 'energyzero',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': 'energyzero_today_energy_current_hour_price',
|
||||
'supported_features': 0,
|
||||
'translation_key': 'current_hour_price',
|
||||
'translation_key': 'current_price',
|
||||
'unique_id': '12345_today_energy_current_hour_price',
|
||||
'unit_of_measurement': '€/kWh',
|
||||
})
|
||||
@@ -100,7 +100,7 @@
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
<EntityStateAttribute.ATTRIBUTION: 'attribution'>: 'Data provided by EnergyZero',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy market price Current hour',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy market price Current price',
|
||||
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: '€/kWh',
|
||||
}),
|
||||
@@ -191,22 +191,21 @@
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Hours priced equal or lower than current - today',
|
||||
'original_name': 'Periods priced equal or lower',
|
||||
'platform': 'energyzero',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': 'energyzero_today_energy_hours_priced_equal_or_lower',
|
||||
'supported_features': 0,
|
||||
'translation_key': 'hours_priced_equal_or_lower',
|
||||
'unique_id': '12345_today_energy_hours_priced_equal_or_lower',
|
||||
'unit_of_measurement': <UnitOfTime.HOURS: 'h'>,
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor[sensor.energyzero_today_energy_hours_priced_equal_or_lower-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
<EntityStateAttribute.ATTRIBUTION: 'attribution'>: 'Data provided by EnergyZero',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy market price Hours priced equal or lower than current - today',
|
||||
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfTime.HOURS: 'h'>,
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy market price Periods priced equal or lower',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.energyzero_today_energy_hours_priced_equal_or_lower',
|
||||
@@ -408,12 +407,12 @@
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Next hour',
|
||||
'original_name': 'Next price',
|
||||
'platform': 'energyzero',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': 'energyzero_today_energy_next_hour_price',
|
||||
'supported_features': 0,
|
||||
'translation_key': 'next_hour_price',
|
||||
'translation_key': 'next_price',
|
||||
'unique_id': '12345_today_energy_next_hour_price',
|
||||
'unit_of_measurement': '€/kWh',
|
||||
})
|
||||
@@ -422,7 +421,7 @@
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
<EntityStateAttribute.ATTRIBUTION: 'attribution'>: 'Data provided by EnergyZero',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy market price Next hour',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy market price Next price',
|
||||
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: '€/kWh',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
|
||||
Reference in New Issue
Block a user