mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
ebusd: added check for monitored conditions validity within correct circuit (#22461)
This commit is contained in:
parent
1bca313421
commit
32844bb318
@ -23,15 +23,29 @@ SERVICE_EBUSD_WRITE = 'ebusd_write'
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=15)
|
||||
|
||||
|
||||
def verify_ebusd_config(config):
|
||||
"""Verify eBusd config."""
|
||||
circuit = config[CONF_CIRCUIT]
|
||||
for condition in config[CONF_MONITORED_CONDITIONS]:
|
||||
if condition not in SENSOR_TYPES[circuit]:
|
||||
raise vol.Invalid(
|
||||
"Condition '" + condition + "' not in '" + circuit + "'.")
|
||||
return config
|
||||
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Required(CONF_CIRCUIT): cv.string,
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_MONITORED_CONDITIONS, default=[]): vol.All(
|
||||
cv.ensure_list, [vol.In(SENSOR_TYPES['700'])])
|
||||
})
|
||||
DOMAIN: vol.Schema(
|
||||
vol.All({
|
||||
vol.Required(CONF_CIRCUIT): cv.string,
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_MONITORED_CONDITIONS, default=[]):
|
||||
cv.ensure_list,
|
||||
},
|
||||
verify_ebusd_config)
|
||||
)
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user