mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add today's remaining production estimate (#91965)
This commit is contained in:
parent
32ffedd365
commit
64e4414a5e
@ -28,6 +28,15 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
|
|||||||
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
suggested_display_precision=1,
|
suggested_display_precision=1,
|
||||||
),
|
),
|
||||||
|
ForecastSolarSensorEntityDescription(
|
||||||
|
key="energy_production_today_remaining",
|
||||||
|
name="Estimated energy production - remaining today",
|
||||||
|
state=lambda estimate: estimate.energy_production_today_remaining,
|
||||||
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
|
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||||
|
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
|
suggested_display_precision=1,
|
||||||
|
),
|
||||||
ForecastSolarSensorEntityDescription(
|
ForecastSolarSensorEntityDescription(
|
||||||
key="energy_production_tomorrow",
|
key="energy_production_tomorrow",
|
||||||
name="Estimated energy production - tomorrow",
|
name="Estimated energy production - tomorrow",
|
||||||
|
@ -34,6 +34,7 @@ async def async_get_config_entry_diagnostics(
|
|||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"energy_production_today": coordinator.data.energy_production_today,
|
"energy_production_today": coordinator.data.energy_production_today,
|
||||||
|
"energy_production_today_remaining": coordinator.data.energy_production_today_remaining,
|
||||||
"energy_production_tomorrow": coordinator.data.energy_production_tomorrow,
|
"energy_production_tomorrow": coordinator.data.energy_production_tomorrow,
|
||||||
"energy_current_hour": coordinator.data.energy_current_hour,
|
"energy_current_hour": coordinator.data.energy_current_hour,
|
||||||
"power_production_now": coordinator.data.power_production_now,
|
"power_production_now": coordinator.data.power_production_now,
|
||||||
|
@ -72,6 +72,7 @@ def mock_forecast_solar(hass) -> Generator[None, MagicMock, None]:
|
|||||||
estimate.api_rate_limit = 60
|
estimate.api_rate_limit = 60
|
||||||
estimate.account_type.value = "public"
|
estimate.account_type.value = "public"
|
||||||
estimate.energy_production_today = 100000
|
estimate.energy_production_today = 100000
|
||||||
|
estimate.energy_production_today_remaining = 50000
|
||||||
estimate.energy_production_tomorrow = 200000
|
estimate.energy_production_tomorrow = 200000
|
||||||
estimate.power_production_now = 300000
|
estimate.power_production_now = 300000
|
||||||
estimate.power_highest_peak_time_today = datetime(
|
estimate.power_highest_peak_time_today = datetime(
|
||||||
|
@ -34,6 +34,7 @@ async def test_diagnostics(
|
|||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"energy_production_today": 100000,
|
"energy_production_today": 100000,
|
||||||
|
"energy_production_today_remaining": 50000,
|
||||||
"energy_production_tomorrow": 200000,
|
"energy_production_tomorrow": 200000,
|
||||||
"energy_current_hour": 800000,
|
"energy_current_hour": 800000,
|
||||||
"power_production_now": 300000,
|
"power_production_now": 300000,
|
||||||
|
@ -48,6 +48,21 @@ async def test_sensors(
|
|||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
state = hass.states.get("sensor.energy_production_today_remaining")
|
||||||
|
entry = entity_registry.async_get("sensor.energy_production_today_remaining")
|
||||||
|
assert entry
|
||||||
|
assert state
|
||||||
|
assert entry.unique_id == f"{entry_id}_energy_production_today_remaining"
|
||||||
|
assert state.state == "50.0"
|
||||||
|
assert (
|
||||||
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||||
|
== "Solar production forecast Estimated energy production - remaining today"
|
||||||
|
)
|
||||||
|
assert state.attributes.get(ATTR_STATE_CLASS) is None
|
||||||
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.KILO_WATT_HOUR
|
||||||
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||||
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
state = hass.states.get("sensor.energy_production_tomorrow")
|
state = hass.states.get("sensor.energy_production_tomorrow")
|
||||||
entry = entity_registry.async_get("sensor.energy_production_tomorrow")
|
entry = entity_registry.async_get("sensor.energy_production_tomorrow")
|
||||||
assert entry
|
assert entry
|
||||||
|
Loading…
x
Reference in New Issue
Block a user