mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Support for hierarchy of individual energy devices (#132616)
* Support for hierarchy of individual energy devices * update DeviceConsumption dict * change name parent to 'included_in' * Break comment --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
75cd32b742
commit
1ae2cebeb1
@ -139,6 +139,10 @@ class DeviceConsumption(TypedDict):
|
|||||||
# An optional custom name for display in energy graphs
|
# An optional custom name for display in energy graphs
|
||||||
name: str | None
|
name: str | None
|
||||||
|
|
||||||
|
# An optional statistic_id identifying a device
|
||||||
|
# that includes this device's consumption in its total
|
||||||
|
included_in_stat: str | None
|
||||||
|
|
||||||
|
|
||||||
class EnergyPreferences(TypedDict):
|
class EnergyPreferences(TypedDict):
|
||||||
"""Dictionary holding the energy data."""
|
"""Dictionary holding the energy data."""
|
||||||
@ -291,6 +295,7 @@ DEVICE_CONSUMPTION_SCHEMA = vol.Schema(
|
|||||||
{
|
{
|
||||||
vol.Required("stat_consumption"): str,
|
vol.Required("stat_consumption"): str,
|
||||||
vol.Optional("name"): str,
|
vol.Optional("name"): str,
|
||||||
|
vol.Optional("included_in_stat"): str,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -149,7 +149,13 @@ async def test_save_preferences(
|
|||||||
"stat_energy_to": "my_battery_charging",
|
"stat_energy_to": "my_battery_charging",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"device_consumption": [{"stat_consumption": "some_device_usage"}],
|
"device_consumption": [
|
||||||
|
{
|
||||||
|
"stat_consumption": "some_device_usage",
|
||||||
|
"name": "My Device",
|
||||||
|
"included_in_stat": "sensor.some_other_device",
|
||||||
|
}
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
await client.send_json({"id": 6, "type": "energy/save_prefs", **new_prefs})
|
await client.send_json({"id": 6, "type": "energy/save_prefs", **new_prefs})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user