Energyzero - Add sensor entity to pick best hours (#98916)
* Add entity to pick best hours * Add entity also to diagnostics * Remove string translation that doesn't exists --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
@@ -50,6 +50,7 @@ async def async_get_config_entry_diagnostics(
|
||||
"highest_price_time": coordinator.data.energy_today.highest_price_time,
|
||||
"lowest_price_time": coordinator.data.energy_today.lowest_price_time,
|
||||
"percentage_of_max": coordinator.data.energy_today.pct_of_max_price,
|
||||
"hours_priced_equal_or_lower": coordinator.data.energy_today.hours_priced_equal_or_lower,
|
||||
},
|
||||
"gas": {
|
||||
"current_hour_price": get_gas_price(coordinator.data, 0),
|
||||
|
||||
@@ -13,7 +13,13 @@ from homeassistant.components.sensor import (
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CURRENCY_EURO, PERCENTAGE, UnitOfEnergy, UnitOfVolume
|
||||
from homeassistant.const import (
|
||||
CURRENCY_EURO,
|
||||
PERCENTAGE,
|
||||
UnitOfEnergy,
|
||||
UnitOfTime,
|
||||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@@ -114,6 +120,14 @@ SENSORS: tuple[EnergyZeroSensorEntityDescription, ...] = (
|
||||
icon="mdi:percent",
|
||||
value_fn=lambda data: data.energy_today.pct_of_max_price,
|
||||
),
|
||||
EnergyZeroSensorEntityDescription(
|
||||
key="hours_priced_equal_or_lower",
|
||||
translation_key="hours_priced_equal_or_lower",
|
||||
service_type="today_energy",
|
||||
native_unit_of_measurement=UnitOfTime.HOURS,
|
||||
icon="mdi:clock",
|
||||
value_fn=lambda data: data.energy_today.hours_priced_equal_or_lower,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -37,9 +37,6 @@
|
||||
},
|
||||
"hours_priced_equal_or_lower": {
|
||||
"name": "Hours priced equal or lower than current - today"
|
||||
},
|
||||
"hours_priced_equal_or_higher": {
|
||||
"name": "Hours priced equal or higher than current - today"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user