1 """Diagnostics support for easyEnergy."""
3 from __future__
import annotations
5 from datetime
import timedelta
11 from .
import EasyEnergyDataUpdateCoordinator
12 from .const
import DOMAIN
13 from .coordinator
import EasyEnergyData
17 """Get the gas price for a given hour.
20 data: The data object.
21 hours: The number of hours to add to the current time.
24 The gas market price value.
27 if not data.gas_today:
29 return data.gas_today.price_at_time(
30 data.gas_today.utcnow() +
timedelta(hours=hours)
35 hass: HomeAssistant, entry: ConfigEntry
37 """Return diagnostics for a config entry."""
38 coordinator: EasyEnergyDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
45 "current_hour_price": coordinator.data.energy_today.current_usage_price,
46 "next_hour_price": coordinator.data.energy_today.price_at_time(
47 coordinator.data.energy_today.utcnow() +
timedelta(hours=1)
49 "average_price": coordinator.data.energy_today.average_usage_price,
50 "max_price": coordinator.data.energy_today.extreme_usage_prices[1],
51 "min_price": coordinator.data.energy_today.extreme_usage_prices[0],
52 "highest_price_time": coordinator.data.energy_today.highest_usage_price_time,
53 "lowest_price_time": coordinator.data.energy_today.lowest_usage_price_time,
54 "percentage_of_max": coordinator.data.energy_today.pct_of_max_usage,
57 "current_hour_price": coordinator.data.energy_today.current_return_price,
58 "next_hour_price": coordinator.data.energy_today.price_at_time(
59 coordinator.data.energy_today.utcnow() +
timedelta(hours=1),
"return"
61 "average_price": coordinator.data.energy_today.average_return_price,
62 "max_price": coordinator.data.energy_today.extreme_return_prices[1],
63 "min_price": coordinator.data.energy_today.extreme_return_prices[0],
64 "highest_price_time": coordinator.data.energy_today.highest_return_price_time,
65 "lowest_price_time": coordinator.data.energy_today.lowest_return_price_time,
66 "percentage_of_max": coordinator.data.energy_today.pct_of_max_return,
float|None get_gas_price(EasyEnergyData data, int hours)
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, ConfigEntry entry)