mirror of
https://github.com/home-assistant/core
synced 2024-09-06 10:29:55 +02:00
Check if mac is set when more than 2 gateways (#21834)
* Check if mac is set when more than 2 gateways When more than 2 gateways mac is required for each of them. Now voluptuous will require it. * fix line length * remove trailing whitespace * Make it more readable
This commit is contained in:
parent
1aee7a1673
commit
548371e94c
@ -61,8 +61,7 @@ SERVICE_SCHEMA_REMOVE_DEVICE = vol.Schema({
|
||||
})
|
||||
|
||||
|
||||
GATEWAY_CONFIG = vol.Schema({
|
||||
vol.Optional(CONF_MAC, default=None): vol.Any(GW_MAC, None),
|
||||
GATEWAY_CONFIG_MAC_OPT = vol.Schema({
|
||||
vol.Optional(CONF_KEY):
|
||||
vol.All(cv.string, vol.Length(min=16, max=16)),
|
||||
vol.Optional(CONF_HOST): cv.string,
|
||||
@ -70,6 +69,14 @@ GATEWAY_CONFIG = vol.Schema({
|
||||
vol.Optional(CONF_DISABLE, default=False): cv.boolean,
|
||||
})
|
||||
|
||||
GATEWAY_CONFIG_MAC_REQ = vol.Schema({
|
||||
vol.Required(CONF_KEY):
|
||||
vol.All(cv.string, vol.Length(min=16, max=16)),
|
||||
vol.Optional(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_PORT, default=9898): cv.port,
|
||||
vol.Optional(CONF_DISABLE, default=False): cv.boolean,
|
||||
})
|
||||
|
||||
|
||||
def _fix_conf_defaults(config):
|
||||
"""Update some configuration defaults."""
|
||||
@ -89,7 +96,10 @@ def _fix_conf_defaults(config):
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Optional(CONF_GATEWAYS, default={}):
|
||||
vol.All(cv.ensure_list, [GATEWAY_CONFIG], [_fix_conf_defaults]),
|
||||
vol.All(cv.ensure_list, vol.Any(
|
||||
vol.All([GATEWAY_CONFIG_MAC_OPT], vol.Length(max=1)),
|
||||
vol.All([GATEWAY_CONFIG_MAC_REQ], vol.Length(min=2))
|
||||
), [_fix_conf_defaults]),
|
||||
vol.Optional(CONF_INTERFACE, default='any'): cv.string,
|
||||
vol.Optional(CONF_DISCOVERY_RETRY, default=3): cv.positive_int
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user