mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
Fix template/switch cover example. Fixes #27
This commit is contained in:
parent
4fa7bc196a
commit
7a393c1a3a
5 changed files with 6 additions and 6 deletions
|
@ -100,7 +100,7 @@ ACTIONS_SCHEMA = vol.All(cv.ensure_list, [vol.All({
|
|||
vol.Optional(CONF_SPEED): cv.templatable(fan.validate_fan_speed),
|
||||
}),
|
||||
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
||||
}, cv.has_at_exactly_one_key(*ACTION_KEYS))])
|
||||
}, cv.has_exactly_one_key(*ACTION_KEYS))])
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
DelayAction = esphomelib_ns.DelayAction
|
||||
|
@ -123,7 +123,7 @@ CONDITIONS_SCHEMA = vol.All(cv.ensure_list, [vol.All({
|
|||
vol.Optional(CONF_BELOW): vol.Coerce(float),
|
||||
}), cv.has_at_least_one_key(CONF_ABOVE, CONF_BELOW)),
|
||||
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
||||
}), cv.has_at_exactly_one_key(*CONDITION_KEYS)])
|
||||
}), cv.has_exactly_one_key(*CONDITION_KEYS)])
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
AndCondition = esphomelib_ns.AndCondition
|
||||
|
|
|
@ -14,7 +14,7 @@ PLATFORM_SCHEMA = vol.All(cover.PLATFORM_SCHEMA.extend({
|
|||
vol.Optional(CONF_OPEN_ACTION): automation.ACTIONS_SCHEMA,
|
||||
vol.Optional(CONF_CLOSE_ACTION): automation.ACTIONS_SCHEMA,
|
||||
vol.Optional(CONF_STOP_ACTION): automation.ACTIONS_SCHEMA,
|
||||
}).extend(cover.COVER_SCHEMA.schema), cv.has_at_exactly_one_key(CONF_LAMBDA, CONF_OPTIMISTIC))
|
||||
}).extend(cover.COVER_SCHEMA.schema), cv.has_at_least_one_key(CONF_LAMBDA, CONF_OPTIMISTIC))
|
||||
|
||||
MakeTemplateCover = Application.MakeTemplateCover
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ FILTERS_SCHEMA = vol.All(cv.ensure_list, [vol.All({
|
|||
vol.Optional(CONF_HEARTBEAT): cv.positive_time_period_milliseconds,
|
||||
vol.Optional(CONF_DEBOUNCE): cv.positive_time_period_milliseconds,
|
||||
vol.Optional(CONF_OR): validate_recursive_filter,
|
||||
}, cv.has_at_exactly_one_key(*FILTER_KEYS))])
|
||||
}, cv.has_exactly_one_key(*FILTER_KEYS))])
|
||||
|
||||
SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend({
|
||||
cv.GenerateID('mqtt_sensor', CONF_MQTT_ID): cv.register_variable_id,
|
||||
|
|
|
@ -13,7 +13,7 @@ PLATFORM_SCHEMA = vol.All(switch.PLATFORM_SCHEMA.extend({
|
|||
vol.Optional(CONF_OPTIMISTIC): cv.boolean,
|
||||
vol.Optional(CONF_TURN_OFF_ACTION): automation.ACTIONS_SCHEMA,
|
||||
vol.Optional(CONF_TURN_ON_ACTION): automation.ACTIONS_SCHEMA,
|
||||
}).extend(switch.SWITCH_SCHEMA.schema), cv.has_at_exactly_one_key(CONF_LAMBDA, CONF_OPTIMISTIC))
|
||||
}).extend(switch.SWITCH_SCHEMA.schema), cv.has_at_least_one_key(CONF_LAMBDA, CONF_OPTIMISTIC))
|
||||
|
||||
MakeTemplateSwitch = Application.MakeTemplateSwitch
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ def has_at_least_one_key(*keys):
|
|||
return validate
|
||||
|
||||
|
||||
def has_at_exactly_one_key(*keys):
|
||||
def has_exactly_one_key(*keys):
|
||||
def validate(obj):
|
||||
if not isinstance(obj, dict):
|
||||
raise vol.Invalid('expected dictionary')
|
||||
|
|
Loading…
Reference in a new issue