mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 08:51:46 -04:00
Make gas & water sources nameable (#170447)
This commit is contained in:
@@ -186,6 +186,9 @@ class GasSourceType(TypedDict):
|
||||
entity_energy_price: str | None # entity_id of an entity providing price ($/m³)
|
||||
number_energy_price: float | None # Price for energy ($/m³)
|
||||
|
||||
# An optional custom name for display in energy graphs
|
||||
name: str | None
|
||||
|
||||
|
||||
class WaterSourceType(TypedDict):
|
||||
"""Dictionary holding the source of water consumption."""
|
||||
@@ -206,6 +209,9 @@ class WaterSourceType(TypedDict):
|
||||
entity_energy_price: str | None # entity_id of an entity providing price ($/m³)
|
||||
number_energy_price: float | None # Price for energy ($/m³)
|
||||
|
||||
# An optional custom name for display in energy graphs
|
||||
name: str | None
|
||||
|
||||
|
||||
type SourceType = (
|
||||
GridSourceType
|
||||
@@ -502,6 +508,7 @@ GAS_SOURCE_SCHEMA = vol.All(
|
||||
vol.Remove("entity_energy_from"): vol.Any(str, None),
|
||||
vol.Optional("entity_energy_price"): vol.Any(str, None),
|
||||
vol.Optional("number_energy_price"): vol.Any(vol.Coerce(float), None),
|
||||
vol.Optional("name"): str,
|
||||
}
|
||||
),
|
||||
_reject_price_for_external_stat(stat_key="stat_energy_from"),
|
||||
@@ -515,6 +522,7 @@ WATER_SOURCE_SCHEMA = vol.All(
|
||||
vol.Optional("stat_cost"): vol.Any(str, None),
|
||||
vol.Optional("entity_energy_price"): vol.Any(str, None),
|
||||
vol.Optional("number_energy_price"): vol.Any(vol.Coerce(float), None),
|
||||
vol.Optional("name"): str,
|
||||
}
|
||||
),
|
||||
_reject_price_for_external_stat(stat_key="stat_energy_from"),
|
||||
|
||||
@@ -147,6 +147,8 @@ async def test_save_preferences(
|
||||
"stat_rate": "my_battery_power",
|
||||
"stat_soc": "sensor.my_battery_state_of_charge",
|
||||
},
|
||||
{"type": "gas", "stat_energy_from": "sensor.gas", "name": "My gas"},
|
||||
{"type": "water", "stat_energy_from": "sensor.water", "name": "My water"},
|
||||
],
|
||||
"device_consumption": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user