Makes sure YAML defined tariffs are unique (#69151)

pull/69171/head
Diogo Gomes 2022-04-03 04:41:03 +01:00 committed by GitHub
parent ccd5ada341
commit 6389959fb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -85,7 +85,7 @@ METER_CONFIG_SCHEMA = vol.Schema(
vol.Optional(CONF_METER_DELTA_VALUES, default=False): cv.boolean,
vol.Optional(CONF_METER_NET_CONSUMPTION, default=False): cv.boolean,
vol.Optional(CONF_TARIFFS, default=[]): vol.All(
cv.ensure_list, [cv.string]
cv.ensure_list, vol.Unique(), [cv.string]
),
vol.Optional(CONF_CRON_PATTERN): validate_cron_pattern,
},

View File

@ -226,6 +226,27 @@ async def test_state(hass, yaml_config, config_entry_config):
assert state.state == "0.123"
@pytest.mark.parametrize(
"yaml_config",
(
(
{
"utility_meter": {
"energy_bill": {
"source": "sensor.energy",
"tariffs": ["onpeak", "onpeak"],
}
}
},
None,
),
),
)
async def test_not_unique_tariffs(hass, yaml_config):
"""Test utility sensor state initializtion."""
assert not await async_setup_component(hass, DOMAIN, yaml_config)
@pytest.mark.parametrize(
"yaml_config,config_entry_config",
(